]> git.sesse.net Git - vlc/blob - modules/gui/qt4/adapters/seekpoints.cpp
Qt: SoutInputBox: show decoded mrl (fix #8436 part1)
[vlc] / modules / gui / qt4 / adapters / seekpoints.cpp
1 /*****************************************************************************
2  * seekpoints.cpp : Chapters & Bookmarks (menu)
3  *****************************************************************************
4  * Copyright © 2011 the VideoLAN team
5  *
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * ( at your option ) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20  *****************************************************************************/
21
22
23 #include "recents.hpp"
24 #include "dialogs_provider.hpp"
25 #include "menus.hpp"
26
27 #include "seekpoints.hpp"
28
29 #include "qt4.hpp"
30 #include "input_manager.hpp"
31
32 SeekPoints::SeekPoints( QObject *parent, intf_thread_t *p_intf_ ) :
33     QObject( parent ), p_intf( p_intf_ )
34 {}
35
36 void SeekPoints::update()
37 {
38     input_title_t *p_title = NULL;
39     input_thread_t *p_input_thread = playlist_CurrentInput( THEPL );
40     int i_title_id = -1;
41     if( !p_input_thread ) { pointsList.clear(); return; }
42
43     if ( input_Control( p_input_thread, INPUT_GET_TITLE_INFO, &p_title, &i_title_id )
44         != VLC_SUCCESS )
45     {
46         vlc_object_release( p_input_thread );
47         pointsList.clear();
48         return;
49     }
50
51     vlc_object_release( p_input_thread );
52
53     if( !p_title )
54         return;
55
56     /* lock here too, as update event is triggered by an external thread */
57     if ( !access() ) return;
58     pointsList.clear();
59     if ( p_title->i_seekpoint > 0 )
60     {
61         /* first check the last point to see if we have filled time offsets (> 0) */
62         if ( p_title->seekpoint[p_title->i_seekpoint - 1]->i_time_offset > 0 )
63         {
64             for ( int i=0; i<p_title->i_seekpoint ; i++ )
65                 pointsList << SeekPoint( p_title->seekpoint[i] );
66         }
67     }
68     vlc_input_title_Delete( p_title );
69     release();
70 }
71
72 QList<SeekPoint> const SeekPoints::getPoints()
73 {
74     QList<SeekPoint> copy;
75     if ( access() )
76     {
77         copy = pointsList;
78         release();
79     }
80     return copy;
81 }
82
83 bool SeekPoints::jumpTo( int i_chapterindex )
84 {
85     vlc_value_t val;
86     val.i_int = i_chapterindex;
87     input_thread_t *p_input_thread = playlist_CurrentInput( THEPL );
88     if( !p_input_thread ) return false;
89     bool b_succ = var_Set( p_input_thread, "chapter", val );
90     vlc_object_release( p_input_thread );
91     return ( b_succ == VLC_SUCCESS );
92 }