repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / mediaplayer / Controller.h
blob45ec5a22325cc49f52947f740c97e2a18c4941b0
1 /*
2 * Controller.h - Media Player for the Haiku Operating System
4 * Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de>
5 * Copyright (C) 2007-2008 Stephan Aßmus <superstippi@gmx.de> (MIT Ok)
7 * Released under the terms of the MIT license.
8 */
9 #ifndef __CONTROLLER_H
10 #define __CONTROLLER_H
13 #include <Entry.h>
14 #include <MediaDefs.h>
15 #include <MediaFormats.h>
16 #include <MediaNode.h>
17 #include <List.h>
18 #include <Locker.h>
19 #include <String.h>
21 #include "ListenerAdapter.h"
22 #include "NodeManager.h"
23 #include "PlaylistItem.h"
26 class AudioTrackSupplier;
27 class TrackSupplier;
28 class PlaylistItem;
29 class ProxyAudioSupplier;
30 class ProxyVideoSupplier;
31 class SubTitles;
32 class VideoTrackSupplier;
33 class VideoView;
36 class Controller : public NodeManager {
37 public:
38 class Listener {
39 public:
40 Listener();
41 virtual ~Listener();
43 virtual void FileFinished();
44 virtual void FileChanged(PlaylistItem* item,
45 status_t result);
47 virtual void VideoTrackChanged(int32 index);
48 virtual void AudioTrackChanged(int32 index);
49 virtual void SubTitleTrackChanged(int32 index);
51 virtual void VideoStatsChanged();
52 virtual void AudioStatsChanged();
54 virtual void PlaybackStateChanged(uint32 state);
55 virtual void PositionChanged(float position);
56 virtual void SeekHandled(int64 seekFrame);
57 virtual void VolumeChanged(float volume);
58 virtual void MutedChanged(bool muted);
61 Controller();
62 virtual ~Controller();
64 // PlaybackManager interface
65 virtual void MessageReceived(BMessage* message);
66 virtual int64 Duration();
68 // NodeManager interface
69 virtual VideoTarget* CreateVideoTarget();
70 virtual VideoSupplier* CreateVideoSupplier();
71 virtual AudioSupplier* CreateAudioSupplier();
73 // Controller
74 status_t SetToAsync(const PlaylistItemRef& item);
75 status_t SetTo(const PlaylistItemRef& item);
76 const PlaylistItem* Item() const
77 { return fItem.Get(); }
78 void PlayerActivated(bool active);
80 void GetSize(int *width, int *height,
81 int* widthAspect = NULL,
82 int* heightAspect = NULL);
84 int AudioTrackCount();
85 int VideoTrackCount();
86 int SubTitleTrackCount();
88 status_t SelectAudioTrack(int n);
89 int CurrentAudioTrack();
90 int AudioTrackChannelCount();
91 status_t SelectVideoTrack(int n);
92 int CurrentVideoTrack();
93 status_t SelectSubTitleTrack(int n);
94 int CurrentSubTitleTrack();
95 const char* SubTitleTrackName(int n);
97 void Stop();
98 void Play();
99 void Pause();
100 void TogglePlaying();
102 uint32 PlaybackState();
104 bigtime_t TimeDuration();
105 bigtime_t TimePosition();
107 virtual void SetVolume(float factor);
108 float Volume();
109 void VolumeUp();
110 void VolumeDown();
111 void ToggleMute();
113 int64 SetPosition(float value);
114 int64 SetFramePosition(int64 frame);
115 int64 SetTimePosition(bigtime_t position);
117 bool HasFile();
118 status_t GetFileFormatInfo(
119 media_file_format* fileFormat);
120 status_t GetCopyright(BString* copyright);
121 status_t GetLocation(BString* location);
122 status_t GetName(BString* name);
123 status_t GetEncodedVideoFormat(media_format* format);
124 status_t GetVideoCodecInfo(media_codec_info* info);
125 status_t GetEncodedAudioFormat(media_format* format);
126 status_t GetAudioCodecInfo(media_codec_info* info);
128 status_t GetMetaData(BMessage* metaData);
129 status_t GetVideoMetaData(int32 track,
130 BMessage* metaData);
131 status_t GetAudioMetaData(int32 track,
132 BMessage* metaData);
134 // video view
135 void SetVideoView(VideoView *view);
137 bool IsOverlayActive();
139 // notification support
140 bool AddListener(Listener* listener);
141 void RemoveListener(Listener* listener);
143 private:
144 void _AdoptGlobalSettings();
146 uint32 _PlaybackState(int32 playingMode) const;
147 int64 _FrameDuration() const;
148 bigtime_t _TimePosition() const;
150 void _NotifyFileChanged(PlaylistItem* item,
151 status_t result) const;
152 void _NotifyFileFinished() const;
153 void _NotifyVideoTrackChanged(int32 index) const;
154 void _NotifyAudioTrackChanged(int32 index) const;
155 void _NotifySubTitleTrackChanged(int32 index) const;
157 void _NotifyVideoStatsChanged() const;
158 void _NotifyAudioStatsChanged() const;
160 void _NotifyPlaybackStateChanged(uint32 state) const;
161 void _NotifyPositionChanged(float position) const;
162 void _NotifySeekHandled(int64 seekFrame) const;
163 void _NotifyVolumeChanged(float volume) const;
164 void _NotifyMutedChanged(bool muted) const;
166 // overridden from PlaybackManager so that we
167 // can use our own Listener mechanism
168 virtual void NotifyPlayModeChanged(int32 mode) const;
169 virtual void NotifyLoopModeChanged(int32 mode) const;
170 virtual void NotifyLoopingEnabledChanged(
171 bool enabled) const;
172 virtual void NotifyVideoBoundsChanged(BRect bounds) const;
173 virtual void NotifyFPSChanged(float fps) const;
174 virtual void NotifyCurrentFrameChanged(int64 frame) const;
175 virtual void NotifySpeedChanged(float speed) const;
176 virtual void NotifyFrameDropped() const;
177 virtual void NotifyStopFrameReached() const;
178 virtual void NotifySeekHandled(int64 seekedFrame) const;
181 private:
182 VideoView* fVideoView;
183 float fVolume;
184 float fActiveVolume;
185 bool fMuted;
187 PlaylistItemRef fItem;
189 ProxyVideoSupplier* fVideoSupplier;
190 ProxyAudioSupplier* fAudioSupplier;
191 VideoTrackSupplier* fVideoTrackSupplier;
192 AudioTrackSupplier* fAudioTrackSupplier;
193 const SubTitles* fSubTitles;
194 int32 fSubTitlesIndex;
196 mutable int64 fCurrentFrame;
197 bigtime_t fDuration;
198 float fVideoFrameRate;
200 mutable int32 fPendingSeekRequests;
201 mutable int64 fSeekFrame;
202 mutable int64 fRequestedSeekFrame;
204 ListenerAdapter fGlobalSettingsListener;
206 bool fAutoplaySetting;
207 // maintains the auto-play setting
208 bool fAutoplay;
209 // is true if the player is already playing
210 // otherwise it's the same as fAutoplaySetting
211 bool fLoopMovies;
212 bool fLoopSounds;
213 uint32 fBackgroundMovieVolumeMode;
215 BList fListeners;
219 #endif // __CONTROLLER_H