2 Copyright 1999, Be Incorporated. All Rights Reserved.
3 This file may be used under the terms of the Be Sample Code License.
6 #include <MediaFormats.h>
14 MediaAddOn::MediaAddOn(image_id imid
)
17 /* Customize these parameters to match those of your node */
18 fFlavorInfo
.name
= (char *)"Demo Video Producer";
19 fFlavorInfo
.info
= (char *)"Demo Video Producer";
20 fFlavorInfo
.kinds
= B_BUFFER_PRODUCER
| B_CONTROLLABLE
;
21 fFlavorInfo
.flavor_flags
= 0;
22 fFlavorInfo
.internal_id
= 0;
23 fFlavorInfo
.possible_count
= 5; // limited to 5 instances (just for testing)
24 fFlavorInfo
.in_format_count
= 0;
25 fFlavorInfo
.in_format_flags
= 0;
26 fFlavorInfo
.in_formats
= NULL
;
27 fFlavorInfo
.out_format_count
= 1;
28 fFlavorInfo
.out_format_flags
= 0;
29 fMediaFormat
.type
= B_MEDIA_RAW_VIDEO
;
30 fMediaFormat
.u
.raw_video
= media_raw_video_format::wildcard
;
31 fMediaFormat
.u
.raw_video
.interlace
= 1;
32 fMediaFormat
.u
.raw_video
.display
.format
= B_RGB32
;
33 fFlavorInfo
.out_formats
= &fMediaFormat
;
38 MediaAddOn::~MediaAddOn()
44 MediaAddOn::InitCheck(const char **out_failure_text
)
46 if (fInitStatus
< B_OK
) {
47 *out_failure_text
= "Unknown error";
55 MediaAddOn::CountFlavors()
57 if (fInitStatus
< B_OK
)
60 /* This addon only supports a single flavor, as defined in the
66 * The pointer to the flavor received only needs to be valid between
67 * successive calls to BMediaAddOn::GetFlavorAt().
70 MediaAddOn::GetFlavorAt(int32 n
, const flavor_info
**out_info
)
72 if (fInitStatus
< B_OK
)
78 /* Return the flavor defined in the constructor */
79 *out_info
= &fFlavorInfo
;
84 MediaAddOn::InstantiateNodeFor(
85 const flavor_info
*info
, BMessage
*config
, status_t
*out_error
)
89 if (fInitStatus
< B_OK
)
92 if (info
->internal_id
!= fFlavorInfo
.internal_id
)
95 /* At most one instance of the node should be instantiated at any given
96 * time. The locking for this restriction may be found in the VideoProducer
98 node
= new VideoProducer(this, fFlavorInfo
.name
, fFlavorInfo
.internal_id
);
99 if (node
&& (node
->InitCheck() < B_OK
)) {
108 make_media_addon(image_id imid
)
110 return new MediaAddOn(imid
);