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 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef __CONTROLLER_H
22 #define __CONTROLLER_H
26 #include <MediaDefs.h>
27 #include <MediaFormats.h>
28 #include <MediaNode.h>
33 #include "ListenerAdapter.h"
34 #include "NodeManager.h"
35 #include "PlaylistItem.h"
38 class AudioTrackSupplier
;
41 class ProxyAudioSupplier
;
42 class ProxyVideoSupplier
;
44 class VideoTrackSupplier
;
48 class Controller
: public NodeManager
{
55 virtual void FileFinished();
56 virtual void FileChanged(PlaylistItem
* item
,
59 virtual void VideoTrackChanged(int32 index
);
60 virtual void AudioTrackChanged(int32 index
);
61 virtual void SubTitleTrackChanged(int32 index
);
63 virtual void VideoStatsChanged();
64 virtual void AudioStatsChanged();
66 virtual void PlaybackStateChanged(uint32 state
);
67 virtual void PositionChanged(float position
);
68 virtual void SeekHandled(int64 seekFrame
);
69 virtual void VolumeChanged(float volume
);
70 virtual void MutedChanged(bool muted
);
74 virtual ~Controller();
76 // PlaybackManager interface
77 virtual void MessageReceived(BMessage
* message
);
78 virtual int64
Duration();
80 // NodeManager interface
81 virtual VideoTarget
* CreateVideoTarget();
82 virtual VideoSupplier
* CreateVideoSupplier();
83 virtual AudioSupplier
* CreateAudioSupplier();
86 status_t
SetToAsync(const PlaylistItemRef
& item
);
87 status_t
SetTo(const PlaylistItemRef
& item
);
88 const PlaylistItem
* Item() const
89 { return fItem
.Get(); }
90 void PlayerActivated(bool active
);
92 void GetSize(int *width
, int *height
,
93 int* widthAspect
= NULL
,
94 int* heightAspect
= NULL
);
96 int AudioTrackCount();
97 int VideoTrackCount();
98 int SubTitleTrackCount();
100 status_t
SelectAudioTrack(int n
);
101 int CurrentAudioTrack();
102 int AudioTrackChannelCount();
103 status_t
SelectVideoTrack(int n
);
104 int CurrentVideoTrack();
105 status_t
SelectSubTitleTrack(int n
);
106 int CurrentSubTitleTrack();
107 const char* SubTitleTrackName(int n
);
112 void TogglePlaying();
114 uint32
PlaybackState();
116 bigtime_t
TimeDuration();
117 bigtime_t
TimePosition();
119 virtual void SetVolume(float factor
);
125 int64
SetPosition(float value
);
126 int64
SetFramePosition(int64 frame
);
127 int64
SetTimePosition(bigtime_t position
);
130 status_t
GetFileFormatInfo(
131 media_file_format
* fileFormat
);
132 status_t
GetCopyright(BString
* copyright
);
133 status_t
GetLocation(BString
* location
);
134 status_t
GetName(BString
* name
);
135 status_t
GetEncodedVideoFormat(media_format
* format
);
136 status_t
GetVideoCodecInfo(media_codec_info
* info
);
137 status_t
GetEncodedAudioFormat(media_format
* format
);
138 status_t
GetAudioCodecInfo(media_codec_info
* info
);
140 status_t
GetMetaData(BMessage
* metaData
);
141 status_t
GetVideoMetaData(int32 track
,
143 status_t
GetAudioMetaData(int32 track
,
147 void SetVideoView(VideoView
*view
);
149 bool IsOverlayActive();
151 // notification support
152 bool AddListener(Listener
* listener
);
153 void RemoveListener(Listener
* listener
);
156 void _AdoptGlobalSettings();
158 uint32
_PlaybackState(int32 playingMode
) const;
159 int64
_FrameDuration() const;
160 bigtime_t
_TimePosition() const;
162 void _NotifyFileChanged(PlaylistItem
* item
,
163 status_t result
) const;
164 void _NotifyFileFinished() const;
165 void _NotifyVideoTrackChanged(int32 index
) const;
166 void _NotifyAudioTrackChanged(int32 index
) const;
167 void _NotifySubTitleTrackChanged(int32 index
) const;
169 void _NotifyVideoStatsChanged() const;
170 void _NotifyAudioStatsChanged() const;
172 void _NotifyPlaybackStateChanged(uint32 state
) const;
173 void _NotifyPositionChanged(float position
) const;
174 void _NotifySeekHandled(int64 seekFrame
) const;
175 void _NotifyVolumeChanged(float volume
) const;
176 void _NotifyMutedChanged(bool muted
) const;
178 // overridden from PlaybackManager so that we
179 // can use our own Listener mechanism
180 virtual void NotifyPlayModeChanged(int32 mode
) const;
181 virtual void NotifyLoopModeChanged(int32 mode
) const;
182 virtual void NotifyLoopingEnabledChanged(
184 virtual void NotifyVideoBoundsChanged(BRect bounds
) const;
185 virtual void NotifyFPSChanged(float fps
) const;
186 virtual void NotifyCurrentFrameChanged(int64 frame
) const;
187 virtual void NotifySpeedChanged(float speed
) const;
188 virtual void NotifyFrameDropped() const;
189 virtual void NotifyStopFrameReached() const;
190 virtual void NotifySeekHandled(int64 seekedFrame
) const;
194 VideoView
* fVideoView
;
199 PlaylistItemRef fItem
;
201 ProxyVideoSupplier
* fVideoSupplier
;
202 ProxyAudioSupplier
* fAudioSupplier
;
203 VideoTrackSupplier
* fVideoTrackSupplier
;
204 AudioTrackSupplier
* fAudioTrackSupplier
;
205 const SubTitles
* fSubTitles
;
206 int32 fSubTitlesIndex
;
208 mutable int64 fCurrentFrame
;
210 float fVideoFrameRate
;
212 mutable int32 fPendingSeekRequests
;
213 mutable int64 fSeekFrame
;
214 mutable int64 fRequestedSeekFrame
;
216 ListenerAdapter fGlobalSettingsListener
;
218 bool fAutoplaySetting
;
219 // maintains the auto-play setting
221 // is true if the player is already playing
222 // otherwise it's the same as fAutoplaySetting
225 uint32 fBackgroundMovieVolumeMode
;
231 #endif // __CONTROLLER_H