2 * This file is a part of BeOS USBVision driver project.
3 * Copyright (c) 2003 by Siarzuk Zharski <imker@gmx.li>
5 * This file may be used under the terms of the BSD License
7 * Skeletal part of this code was inherired from original BeOS sample code,
8 * that is distributed under the terms of the Be Sample Code License.
12 #ifndef _USBVISION_PRODUCER_H
13 #define _USBVISION_PRODUCER_H
15 #include <kernel/OS.h>
16 #include <media/BufferProducer.h>
17 #include <media/Controllable.h>
18 #include <media/MediaDefs.h>
19 #include <media/MediaEventLooper.h>
20 #include <media/MediaNode.h>
21 #include <support/Locker.h>
23 #include "TunerLocale.h"
26 public virtual BMediaEventLooper
,
27 public virtual BBufferProducer
,
28 public virtual BControllable
31 VideoProducer(BMediaAddOn
*addon
,
32 const char *name
, int32 internal_id
);
33 virtual ~VideoProducer();
35 virtual status_t
InitCheck() const { return fInitStatus
; }
39 virtual port_id
ControlPort() const;
40 virtual BMediaAddOn
*AddOn(int32
* internal_id
) const;
41 virtual status_t
HandleMessage(int32 message
, const void *data
,
44 virtual void Preroll();
45 virtual void SetTimeSource(BTimeSource
* time_source
);
46 virtual status_t
RequestCompleted(const media_request_info
& info
);
48 /* BMediaEventLooper */
50 virtual void NodeRegistered();
51 virtual void Start(bigtime_t performance_time
);
52 virtual void Stop(bigtime_t performance_time
, bool immediate
);
53 virtual void Seek(bigtime_t media_time
, bigtime_t performance_time
);
54 virtual void TimeWarp(bigtime_t at_real_time
,
55 bigtime_t to_performance_time
);
56 virtual status_t
AddTimer(bigtime_t at_performance_time
, int32 cookie
);
57 virtual void SetRunMode(run_mode mode
);
58 virtual void HandleEvent(const media_timed_event
*event
,
59 bigtime_t lateness
, bool realTimeEvent
= false);
60 virtual void CleanUpEvent(const media_timed_event
*event
);
61 virtual bigtime_t
OfflineTime();
62 virtual void ControlLoop();
63 virtual status_t
DeleteHook(BMediaNode
* node
);
67 virtual status_t
FormatSuggestionRequested(media_type type
, int32 quality
,
68 media_format
* format
);
69 virtual status_t
FormatProposal(const media_source
&output
,
70 media_format
*format
);
71 virtual status_t
FormatChangeRequested(const media_source
&source
,
72 const media_destination
&destination
,
73 media_format
*io_format
, int32
*_deprecated_
);
74 virtual status_t
GetNextOutput(int32
* cookie
, media_output
* out_output
);
75 virtual status_t
DisposeOutputCookie(int32 cookie
);
76 virtual status_t
SetBufferGroup(const media_source
&for_source
,
77 BBufferGroup
* group
);
78 virtual status_t
VideoClippingChanged(const media_source
&for_source
,
79 int16 num_shorts
, int16
*clip_data
,
80 const media_video_display_info
&display
,
81 int32
* _deprecated_
);
82 virtual status_t
GetLatency(bigtime_t
* out_latency
);
83 virtual status_t
PrepareToConnect(const media_source
&what
,
84 const media_destination
&where
,
86 media_source
*out_source
, char *out_name
);
87 virtual void Connect(status_t error
, const media_source
&source
,
88 const media_destination
&destination
,
89 const media_format
& format
, char *io_name
);
90 virtual void Disconnect(const media_source
& what
,
91 const media_destination
& where
);
92 virtual void LateNoticeReceived(const media_source
& what
,
93 bigtime_t how_much
, bigtime_t performance_time
);
94 virtual void EnableOutput(const media_source
& what
, bool enabled
,
95 int32
* _deprecated_
);
96 virtual status_t
SetPlayRate(int32 numer
,int32 denom
);
97 virtual void AdditionalBufferRequested(const media_source
& source
,
98 media_buffer_id prev_buffer
, bigtime_t prev_time
,
99 const media_seek_tag
* prev_tag
);
100 virtual void LatencyChanged(const media_source
& source
,
101 const media_destination
& destination
,
102 bigtime_t new_latency
, uint32 flags
);
106 virtual status_t
GetParameterValue(int32 id
, bigtime_t
*last_change
,
107 void *value
, size_t *size
);
108 virtual void SetParameterValue(int32 id
, bigtime_t when
,
109 const void *value
, size_t size
);
110 virtual status_t
StartControlPanel(BMessenger
*out_messenger
);
114 void HandleStart(bigtime_t performance_time
);
116 void HandleTimeWarp(bigtime_t performance_time
);
117 void HandleSeek(bigtime_t performance_time
);
118 void HandleParameter(uint32 parameter
);
120 static int32 fInstances
;
122 status_t fInitStatus
;
128 BBufferGroup
*fBufferGroup
;
132 static int32
_frame_generator_(void *data
);
133 int32
FrameGenerator();
135 /* The remaining variables should be declared volatile, but they
136 * are not here to improve the legibility of the sample code. */
139 bigtime_t fPerformanceTimeBase
;
140 bigtime_t fProcessingLatency
;
141 media_output fOutput
;
142 media_raw_video_format fConnectedFormat
;
171 BParameterWeb
*CreateParameterWeb();
174 bigtime_t fLastChannelChange
;
176 bigtime_t fLastVideoInputChange
;
178 bigtime_t fLastAudioInputChange
;
180 bigtime_t fLastBrightnessChange
;
182 bigtime_t fLastContrastChange
;
184 bigtime_t fLastSaturationChange
;
186 bigtime_t fLastHueChange
;
188 bigtime_t fLastCaptureSizeChange
;
189 uint32 fCaptureFormat
;
190 bigtime_t fLastCaptureFormatChange
;
192 bigtime_t fLastStandardChange
;
194 bigtime_t fLastBandwidthChange
;
196 bigtime_t fLastLocaleChange
;
198 bigtime_t fLastVertOffsetChange
;
200 bigtime_t fLastHorzOffsetChange
;
203 bigtime_t fLastColorChange
;
205 Locale::Locales fLocales
;
208 #endif /*_USBVISION_PRODUCER_H*/