BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / apps / mediaplayer / media_node_framework / video / VideoProducer.h
blobe8a5b1c776a0bd864d00d24dbb69e21b80917521
1 /* Copyright (c) 1998-99, Be Incorporated, All Rights Reserved.
2 * Distributed under the terms of the Be Sample Code license.
4 * Copyright (c) 2000-2008, Ingo Weinhold <ingo_weinhold@gmx.de>,
5 * Copyright (c) 2000-2008, Stephan Aßmus <superstippi@gmx.de>,
6 * All Rights Reserved. Distributed under the terms of the MIT license.
7 */
8 #ifndef _VIDEO_PRODUCER_H
9 #define _VIDEO_PRODUCER_H
12 #include <BufferProducer.h>
13 #include <Controllable.h>
14 #include <Locker.h>
15 #include <MediaDefs.h>
16 #include <MediaEventLooper.h>
17 #include <MediaNode.h>
18 #include <OS.h>
19 #include <Rect.h>
22 class NodeManager;
23 class VideoSupplier;
26 class VideoProducer : public virtual BMediaEventLooper,
27 public virtual BBufferProducer {
28 public:
29 VideoProducer(BMediaAddOn* addon, const char* name,
30 int32 internalId, NodeManager* manager,
31 VideoSupplier* supplier);
32 virtual ~VideoProducer();
34 virtual status_t InitCheck() const
35 { return fInitStatus; }
37 // BMediaNode interface
38 public:
39 virtual BMediaAddOn* AddOn(int32* _internalId) const;
40 virtual status_t HandleMessage(int32 message, const void* data,
41 size_t size);
42 protected:
43 virtual void SetTimeSource(BTimeSource* timeSource);
45 // BMediaEventLooper interface
46 protected:
47 virtual void NodeRegistered();
48 virtual void Start(bigtime_t performanceTime);
49 virtual void Stop(bigtime_t performanceTime, bool immediate);
50 virtual void Seek(bigtime_t mediaTime,
51 bigtime_t performanceTime);
52 virtual void HandleEvent(const media_timed_event* event,
53 bigtime_t lateness,
54 bool realTimeEvent = false);
55 virtual status_t DeleteHook(BMediaNode* node);
57 // BBufferProducer interface
58 protected:
59 virtual status_t FormatSuggestionRequested(media_type type,
60 int32 quality, media_format* format);
61 virtual status_t FormatProposal(const media_source &output,
62 media_format* format);
63 virtual status_t FormatChangeRequested(const media_source& source,
64 const media_destination& destination,
65 media_format* ioFormat, int32* _deprecated_);
66 virtual status_t GetNextOutput(int32* cookie,
67 media_output* outOutput);
68 virtual status_t DisposeOutputCookie(int32 cookie);
69 virtual status_t SetBufferGroup(const media_source& forSource,
70 BBufferGroup* group);
71 virtual status_t VideoClippingChanged(const media_source& forSource,
72 int16 numShorts, int16* clipData,
73 const media_video_display_info& display,
74 int32* _deprecated_);
75 virtual status_t GetLatency(bigtime_t* out_latency);
76 virtual status_t PrepareToConnect(const media_source& what,
77 const media_destination& where,
78 media_format* format, media_source* outSource,
79 char* out_name);
80 virtual void Connect(status_t error, const media_source& source,
81 const media_destination& destination,
82 const media_format& format, char* ioName);
83 virtual void Disconnect(const media_source& what,
84 const media_destination& where);
85 virtual void LateNoticeReceived(const media_source& what,
86 bigtime_t howMuch, bigtime_t performanceTime);
87 virtual void EnableOutput(const media_source& what, bool enabled,
88 int32* _deprecated_);
89 virtual status_t SetPlayRate(int32 numer, int32 denom);
90 virtual void AdditionalBufferRequested(
91 const media_source& source,
92 media_buffer_id prevBuffer,
93 bigtime_t prevTime,
94 const media_seek_tag* prevTag);
95 virtual void LatencyChanged(const media_source& source,
96 const media_destination& destination,
97 bigtime_t newLatency, uint32 flags);
99 private:
100 void _HandleStart(bigtime_t performance_time);
101 void _HandleStop();
102 void _HandleTimeWarp(bigtime_t performance_time);
103 void _HandleSeek(bigtime_t performance_time);
105 static int32 _FrameGeneratorThreadEntry(void* data);
106 int32 _FrameGeneratorThread();
108 status_t fInitStatus;
110 int32 fInternalID;
111 BMediaAddOn* fAddOn;
113 BLocker fLock;
114 BBufferGroup* fBufferGroup;
115 BBufferGroup* fUsedBufferGroup;
117 thread_id fThread;
118 sem_id fFrameSync;
120 // The remaining variables should be declared volatile, but they
121 // are not here to improve the legibility of the sample code.
122 int64 fFrame;
123 int64 fFrameBase;
124 bigtime_t fPerformanceTimeBase;
125 bigtime_t fBufferDuration;
126 bigtime_t fBufferLatency;
127 media_output fOutput;
128 media_raw_video_format fConnectedFormat;
129 bool fRunning;
130 bool fConnected;
131 bool fEnabled;
133 NodeManager* fManager;
134 VideoSupplier* fSupplier;
137 #endif // VIDEO_PRODUCER_H