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.
10 #define __CONTROLLER_H
14 #include <MediaDefs.h>
15 #include <MediaFormats.h>
16 #include <MediaNode.h>
21 #include "ListenerAdapter.h"
22 #include "NodeManager.h"
23 #include "PlaylistItem.h"
26 class AudioTrackSupplier
;
29 class ProxyAudioSupplier
;
30 class ProxyVideoSupplier
;
32 class VideoTrackSupplier
;
36 class Controller
: public NodeManager
{
43 virtual void FileFinished();
44 virtual void FileChanged(PlaylistItem
* item
,
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
);
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();
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
);
100 void TogglePlaying();
102 uint32
PlaybackState();
104 bigtime_t
TimeDuration();
105 bigtime_t
TimePosition();
107 virtual void SetVolume(float factor
);
113 int64
SetPosition(float value
);
114 int64
SetFramePosition(int64 frame
);
115 int64
SetTimePosition(bigtime_t position
);
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
,
131 status_t
GetAudioMetaData(int32 track
,
135 void SetVideoView(VideoView
*view
);
137 bool IsOverlayActive();
139 // notification support
140 bool AddListener(Listener
* listener
);
141 void RemoveListener(Listener
* listener
);
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(
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;
182 VideoView
* fVideoView
;
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
;
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
209 // is true if the player is already playing
210 // otherwise it's the same as fAutoplaySetting
213 uint32 fBackgroundMovieVolumeMode
;
219 #endif // __CONTROLLER_H