]> git.tdb.fi Git - xinema.git/blob - remote/source/streamcontrolitem.cpp
Display stream size and codecs on the playback page
[xinema.git] / remote / source / streamcontrolitem.cpp
1 #include "streamcontrolitem.h"
2 #include "xinemacontrolitem.h"
3
4 StreamControlItem::StreamControlItem():
5         control(0)
6 {
7 }
8
9 void StreamControlItem::set_control(XinemaControlItem *c)
10 {
11         if(control)
12                 disconnect(control, 0, this, 0);
13
14         control = c;
15         if(control)
16         {
17                 XinemaControl &xc = control->get_control();
18                 connect(&xc, &XinemaControl::playback_state_changed, this, &StreamControlItem::playback_state_changed);
19                 connect(&xc, &XinemaControl::title_changed, this, &StreamControlItem::title_changed);
20                 connect(&xc, &XinemaControl::duration_changed, this, &StreamControlItem::duration_changed);
21                 connect(&xc, &XinemaControl::position_changed, this, &StreamControlItem::position_changed);
22                 connect(&xc, &XinemaControl::size_changed, this, &StreamControlItem::size_changed);
23                 connect(&xc, &XinemaControl::framerate_changed, this, &StreamControlItem::framerate_changed);
24                 connect(&xc, &XinemaControl::codecs_changed, this, &StreamControlItem::codecs_changed);
25                 connect(&xc, &XinemaControl::channels_changed, this, &StreamControlItem::control_channels_changed);
26                 connect(&xc, &XinemaControl::current_audio_channel_changed, this, &StreamControlItem::current_audio_channel_changed);
27                 connect(&xc, &XinemaControl::current_spu_channel_changed, this, &StreamControlItem::current_spu_channel_changed);
28         }
29
30         emit control_changed();
31
32         if(control)
33         {
34                 emit playback_state_changed();
35                 emit title_changed();
36                 emit duration_changed();
37                 emit position_changed();
38                 emit size_changed();
39                 emit framerate_changed();
40                 emit codecs_changed();
41                 emit channels_changed();
42                 emit current_audio_channel_changed();
43                 emit current_spu_channel_changed();
44         }
45 }
46
47 StreamControlItem::PlaybackState StreamControlItem::get_playback_state() const
48 {
49         if(!control)
50                 return Stopped;
51
52         return static_cast<PlaybackState>(control->get_control().get_playback_state());
53 }
54
55 void StreamControlItem::set_playback_state(PlaybackState state)
56 {
57         if(!control)
58                 return;
59
60         XinemaControl &xc = control->get_control();
61         if(state==Stopped)
62                 xc.stop();
63         else if(state==Paused)
64                 xc.pause();
65         else if(state==Playing)
66                 xc.play();
67 }
68
69 QString StreamControlItem::get_title() const
70 {
71         if(!control)
72                 return QString();
73
74         return control->get_control().get_title();
75 }
76
77 float StreamControlItem::get_duration() const
78 {
79         if(!control)
80                 return 0;
81
82         return control->get_control().get_duration();
83 }
84
85 void StreamControlItem::set_position(float pos)
86 {
87         if(control)
88                 control->get_control().seek(pos);
89 }
90
91 float StreamControlItem::get_position() const
92 {
93         if(!control)
94                 return 0;
95
96         return control->get_control().get_position();
97 }
98
99 QSize StreamControlItem::get_video_size() const
100 {
101         if(!control)
102                 return QSize();
103
104         return control->get_control().get_video_size();
105 }
106
107 float StreamControlItem::get_framerate() const
108 {
109         if(!control)
110                 return 0.0f;
111
112         return control->get_control().get_framerate();
113 }
114
115 QString StreamControlItem::get_video_codec() const
116 {
117         if(!control)
118                 return QString();
119
120         return control->get_control().get_video_codec();
121 }
122
123 QString StreamControlItem::get_audio_codec() const
124 {
125         if(!control)
126                 return QString();
127
128         return control->get_control().get_audio_codec();
129 }
130
131 QStringList StreamControlItem::get_audio_channels() const
132 {
133         if(!control)
134                 return QStringList();
135
136         return control->get_control().get_audio_channels();
137 }
138
139 QStringList StreamControlItem::get_spu_channels() const
140 {
141         if(!control)
142                 return QStringList();
143
144         return control->get_control().get_spu_channels();
145 }
146
147 void StreamControlItem::select_audio_channel(int chan)
148 {
149         if(control)
150                 control->get_control().select_audio_channel(chan);
151 }
152
153 void StreamControlItem::select_spu_channel(int chan)
154 {
155         if(control)
156                 control->get_control().select_spu_channel(chan);
157 }
158
159 int StreamControlItem::get_current_audio_channel() const
160 {
161         if(!control)
162                 return -1;
163
164         return control->get_control().get_current_audio_channel();
165 }
166
167 int StreamControlItem::get_current_spu_channel() const
168 {
169         if(!control)
170                 return -1;
171
172         return control->get_control().get_current_spu_channel();
173 }
174
175 void StreamControlItem::control_channels_changed()
176 {
177         emit channels_changed();
178         emit current_audio_channel_changed();
179         emit current_spu_channel_changed();
180 }