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. 4 * 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" 11 12 13 #include <stdio.h> 14 #include <string.h> 15 16 17 VideoWindowAddOn::VideoWindowAddOn(image_id id) 18 : BMediaAddOn(id) 19 { 20 CALLED(); 21 22 fInputFormat.type = B_MEDIA_RAW_VIDEO; 23 fInputFormat.u.raw_video = media_raw_video_format::wildcard; 24 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; 37 } 38 39 40 VideoWindowAddOn::~VideoWindowAddOn() 41 { 42 } 43 44 45 46 bool 47 VideoWindowAddOn::WantsAutoStart() 48 { 49 CALLED(); 50 return false; 51 } 52 53 54 int32 55 VideoWindowAddOn::CountFlavors() 56 { 57 CALLED(); 58 return 1; 59 } 60 61 62 status_t 63 VideoWindowAddOn::GetFlavorAt(int32 cookie, const flavor_info **flavorInfo) 64 { 65 CALLED(); 66 if (cookie != 0) 67 return B_BAD_INDEX; 68 69 *flavorInfo = &fInfo; 70 return B_OK; 71 } 72 73 74 BMediaNode* 75 VideoWindowAddOn::InstantiateNodeFor(const flavor_info *info, BMessage*, status_t *outError) 76 { 77 CALLED(); 78 if (!outError) 79 return NULL; 80 81 if (info->in_formats[0].type != B_MEDIA_RAW_VIDEO) { 82 *outError = B_MEDIA_BAD_FORMAT; 83 return NULL; 84 } 85 86 BRect size; 87 if (info->in_formats[0].u.raw_video.display.line_width != 0) 88 size.right = info->in_formats[0].u.raw_video.display.line_width; 89 else 90 size.right = 320; 91 if (info->in_formats[0].u.raw_video.display.line_count != 0) 92 size.bottom = info->in_formats[0].u.raw_video.display.line_count; 93 else 94 size.bottom = 240; 95 96 VideoNode* node = new VideoNode("Video Node", this, info->internal_id); 97 98 return node; 99 } 100 101 102 extern "C" BMediaAddOn *make_media_addon(image_id id) 103 { 104 return new VideoWindowAddOn(id); 105 } 106