BTRFS: Implement BTree::Path and change _Find.
[haiku.git] / src / add-ons / media / media-add-ons / videowindow / VideoAddOn.cpp
blobe8a08bdb4072d0a1a8512db7fa2ad17314de5def
1 /*
2 * Copyright (C) 2006-2008 Marcus Overhagen <marcus@overhagen.de>. All rights reserved.
3 * Copyright (C) 2008 Maurice Kalinowski <haiku@kaldience.com>. All rights reserved.
5 * Distributed under the terms of the MIT License.
6 */
7 #include "VideoAddOn.h"
8 #include "VideoNode.h"
9 #include "VideoView.h"
10 #include "debug.h"
13 #include <stdio.h>
14 #include <string.h>
17 VideoWindowAddOn::VideoWindowAddOn(image_id id)
18 : BMediaAddOn(id)
20 CALLED();
22 fInputFormat.type = B_MEDIA_RAW_VIDEO;
23 fInputFormat.u.raw_video = media_raw_video_format::wildcard;
25 fInfo.internal_id = 0;
26 fInfo.name = strdup("VideoWindow Consumer");
27 fInfo.info = strdup("This node displays a simple video window");
28 fInfo.kinds = B_BUFFER_CONSUMER;
29 fInfo.flavor_flags = 0;
30 fInfo.possible_count = 0;
31 fInfo.in_format_count = 1;
32 fInfo.in_format_flags = 0;
33 fInfo.in_formats = &fInputFormat;
34 fInfo.out_format_count = 0;
35 fInfo.out_formats = 0;
36 fInfo.out_format_flags = 0;
40 VideoWindowAddOn::~VideoWindowAddOn()
46 bool
47 VideoWindowAddOn::WantsAutoStart()
49 CALLED();
50 return false;
54 int32
55 VideoWindowAddOn::CountFlavors()
57 CALLED();
58 return 1;
62 status_t
63 VideoWindowAddOn::GetFlavorAt(int32 cookie, const flavor_info **flavorInfo)
65 CALLED();
66 if (cookie != 0)
67 return B_BAD_INDEX;
68 if (!flavorInfo || !*flavorInfo)
69 return B_ERROR;
71 *flavorInfo = &fInfo;
72 return B_OK;
76 BMediaNode*
77 VideoWindowAddOn::InstantiateNodeFor(const flavor_info *info, BMessage*, status_t *outError)
79 CALLED();
80 if (!outError)
81 return NULL;
83 if (info->in_formats[0].type != B_MEDIA_RAW_VIDEO) {
84 *outError = B_MEDIA_BAD_FORMAT;
85 return NULL;
88 BRect size;
89 if (info->in_formats[0].u.raw_video.display.line_width != 0)
90 size.right = info->in_formats[0].u.raw_video.display.line_width;
91 else
92 size.right = 320;
93 if (info->in_formats[0].u.raw_video.display.line_count != 0)
94 size.bottom = info->in_formats[0].u.raw_video.display.line_count;
95 else
96 size.bottom = 240;
98 VideoNode* node = new VideoNode("Video Node", this, info->internal_id);
100 return node;
104 extern "C" BMediaAddOn *make_media_addon(image_id id)
106 return new VideoWindowAddOn(id);