2 * Copyright 2004-2008, François Revol, <revol@free.fr>.
3 * Distributed under the terms of the MIT License.
5 #ifndef _VIDEO_PRODUCER_H
6 #define _VIDEO_PRODUCER_H
9 #include <media/BufferProducer.h>
10 #include <media/Controllable.h>
11 #include <media/MediaDefs.h>
12 #include <media/MediaEventLooper.h>
13 #include <media/MediaNode.h>
14 #include <support/Locker.h>
15 #include <support/String.h>
22 public virtual BMediaEventLooper
,
23 public virtual BBufferProducer
,
24 public virtual BControllable
{
26 VideoProducer(BMediaAddOn
*addon
, CamDevice
*dev
,
27 const char *name
, int32 internal_id
);
28 virtual ~VideoProducer();
30 virtual status_t
InitCheck() const { return fInitStatus
; }
35 virtual port_id
ControlPort() const;
36 virtual BMediaAddOn
*AddOn(int32
* internal_id
) const;
37 virtual status_t
HandleMessage(int32 message
, const void *data
,
40 virtual void Preroll();
41 virtual void SetTimeSource(BTimeSource
* time_source
);
42 virtual status_t
RequestCompleted(const media_request_info
& info
);
44 /* BMediaEventLooper */
46 virtual void NodeRegistered();
47 virtual void Start(bigtime_t performance_time
);
48 virtual void Stop(bigtime_t performance_time
, bool immediate
);
49 virtual void Seek(bigtime_t media_time
, bigtime_t performance_time
);
50 virtual void TimeWarp(bigtime_t at_real_time
,
51 bigtime_t to_performance_time
);
52 virtual status_t
AddTimer(bigtime_t at_performance_time
, int32 cookie
);
53 virtual void SetRunMode(run_mode mode
);
54 virtual void HandleEvent(const media_timed_event
*event
,
55 bigtime_t lateness
, bool realTimeEvent
= false);
56 virtual void CleanUpEvent(const media_timed_event
*event
);
57 virtual bigtime_t
OfflineTime();
58 virtual void ControlLoop();
59 virtual status_t
DeleteHook(BMediaNode
* node
);
63 virtual status_t
FormatSuggestionRequested(media_type type
, int32 quality
,
64 media_format
* format
);
65 virtual status_t
FormatProposal(const media_source
&output
,
66 media_format
*format
);
67 virtual status_t
FormatChangeRequested(const media_source
&source
,
68 const media_destination
&destination
,
69 media_format
*io_format
, int32
*_deprecated_
);
70 virtual status_t
GetNextOutput(int32
* cookie
, media_output
* out_output
);
71 virtual status_t
DisposeOutputCookie(int32 cookie
);
72 virtual status_t
SetBufferGroup(const media_source
&for_source
,
73 BBufferGroup
* group
);
74 virtual status_t
VideoClippingChanged(const media_source
&for_source
,
75 int16 num_shorts
, int16
*clip_data
,
76 const media_video_display_info
&display
,
77 int32
* _deprecated_
);
78 virtual status_t
GetLatency(bigtime_t
* out_latency
);
79 virtual status_t
PrepareToConnect(const media_source
&what
,
80 const media_destination
&where
,
82 media_source
*out_source
, char *out_name
);
83 virtual void Connect(status_t error
, const media_source
&source
,
84 const media_destination
&destination
,
85 const media_format
& format
, char *io_name
);
86 virtual void Disconnect(const media_source
& what
,
87 const media_destination
& where
);
88 virtual void LateNoticeReceived(const media_source
& what
,
89 bigtime_t how_much
, bigtime_t performance_time
);
90 virtual void EnableOutput(const media_source
& what
, bool enabled
,
91 int32
* _deprecated_
);
92 virtual status_t
SetPlayRate(int32 numer
,int32 denom
);
93 virtual void AdditionalBufferRequested(const media_source
& source
,
94 media_buffer_id prev_buffer
, bigtime_t prev_time
,
95 const media_seek_tag
* prev_tag
);
96 virtual void LatencyChanged(const media_source
& source
,
97 const media_destination
& destination
,
98 bigtime_t new_latency
, uint32 flags
);
102 virtual status_t
GetParameterValue(int32 id
, bigtime_t
*last_change
,
103 void *value
, size_t *size
);
104 virtual void SetParameterValue(int32 id
, bigtime_t when
,
105 const void *value
, size_t size
);
106 virtual status_t
StartControlPanel(BMessenger
*out_messenger
);
110 void HandleStart(bigtime_t performance_time
);
112 void HandleTimeWarp(bigtime_t performance_time
);
113 void HandleSeek(bigtime_t performance_time
);
117 static int32 fInstances
;
119 status_t fInitStatus
;
123 CamDevice
*fCamDevice
;
126 BBufferGroup
*fBufferGroup
;
130 static int32
_frame_generator_(void *data
);
131 int32
FrameGenerator();
133 /* The remaining variables should be declared volatile, but they
134 * are not here to improve the legibility of the sample code. */
137 bigtime_t fPerformanceTimeBase
;
138 bigtime_t fProcessingLatency
;
139 media_output fOutput
;
140 media_raw_video_format fConnectedFormat
;
148 P_LAST
// first available for addons
152 bigtime_t fLastColorChange
; // TODO: rename