1 /* 2 * Copyright (c) 2000-2008, Ingo Weinhold <ingo_weinhold@gmx.de>, 3 * Copyright (c) 2000-2008, Stephan Aßmus <superstippi@gmx.de>, 4 * All Rights Reserved. Distributed under the terms of the MIT license. 5 */ 6 7 //! This class controls our media nodes and general playback 8 9 #ifndef NODE_MANAGER_H 10 #define NODE_MANAGER_H 11 12 #include <MediaNode.h> 13 14 #include "PlaybackManager.h" 15 16 class BMediaRoster; 17 class AudioProducer; 18 class VideoTarget; 19 class VideoProducer; 20 class VideoConsumer; 21 class AudioSupplier; 22 class VideoSupplier; 23 24 class NodeManager : public PlaybackManager { 25 public: 26 NodeManager(); 27 virtual ~NodeManager(); 28 29 // must be implemented in derived classes 30 virtual VideoTarget* CreateVideoTarget() = 0; 31 virtual VideoSupplier* CreateVideoSupplier() = 0; 32 virtual AudioSupplier* CreateAudioSupplier() = 0; 33 34 // NodeManager 35 enum { 36 AUDIO_AND_VIDEO = 0, 37 VIDEO_ONLY, 38 AUDIO_ONLY 39 }; 40 41 status_t Init(BRect videoBounds, float videoFrameRate, 42 color_space preferredVideoFormat, 43 int32 loopingMode, 44 bool loopingEnabled, 45 float speed, 46 uint32 enabledNodes, 47 bool useOverlays); 48 status_t InitCheck(); 49 // only call this if the 50 // media_server has died! 51 status_t CleanupNodes(); 52 53 status_t FormatChanged(BRect videoBounds, 54 float videoFrameRate, 55 color_space preferredVideoFormat, 56 uint32 enabledNodes, 57 bool useOverlays, 58 bool force = false); 59 virtual void SetPlayMode(int32 mode, 60 bool continuePlaying = true); 61 62 virtual bigtime_t RealTimeForTime(bigtime_t time) const; 63 virtual bigtime_t TimeForRealTime(bigtime_t time) const; 64 65 virtual void SetCurrentAudioTime(bigtime_t time); 66 67 void SetVideoBounds(BRect bounds); 68 virtual BRect VideoBounds() const; 69 70 void SetVideoTarget(VideoTarget* vcTarget); 71 VideoTarget* GetVideoTarget() const; 72 73 virtual void SetVolume(float percent); 74 75 void SetPeakListener(BHandler* handler); 76 77 private: 78 status_t _SetUpNodes(color_space preferredVideoFormat, 79 uint32 enabledNodes, bool useOverlays); 80 status_t _SetUpVideoNodes( 81 color_space preferredVideoFormat, 82 bool useOverlays); 83 status_t _SetUpAudioNodes(); 84 status_t _TearDownNodes(bool disconnect = true); 85 status_t _StartNodes(); 86 void _StopNodes(); 87 88 private: 89 struct Connection { 90 Connection(); 91 92 media_node producer; 93 media_node consumer; 94 media_source source; 95 media_destination destination; 96 media_format format; 97 bool connected; 98 }; 99 100 private: 101 BMediaRoster* fMediaRoster; 102 103 // media nodes 104 AudioProducer* fAudioProducer; 105 VideoConsumer* fVideoConsumer; 106 VideoProducer* fVideoProducer; 107 media_node fTimeSource; 108 109 Connection fAudioConnection; 110 Connection fVideoConnection; 111 112 bigtime_t fPerformanceTimeBase; 113 114 status_t fStatus; 115 // 116 VideoTarget* fVideoTarget; 117 AudioSupplier* fAudioSupplier; 118 VideoSupplier* fVideoSupplier; 119 BRect fVideoBounds; 120 121 BHandler* fPeakListener; 122 }; 123 124 125 #endif // NODE_MANAGER_H 126