1 /* 2 * Copyright (C) 2006 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 #ifndef __VIDEO_NODE_H_ 8 #define __VIDEO_NODE_H_ 9 10 11 #include <BufferConsumer.h> 12 #include <MediaEventLooper.h> 13 14 15 class BBitmap; 16 class BLocker; 17 class BWindow; 18 class VideoView; 19 class VideoWindow; 20 21 22 class VideoNode : public BMediaEventLooper, public BBufferConsumer 23 { 24 public: 25 VideoNode(const char *name); 26 VideoNode(const char *name, BMediaAddOn* addon, int32 id); 27 ~VideoNode(); 28 29 void SetOverlayEnabled(bool yesno); 30 bool IsOverlayActive(); 31 32 void LockBitmap(); 33 BBitmap * Bitmap(); 34 void UnlockBitmap(); 35 36 protected: 37 BMediaAddOn * AddOn(int32 *internal_id) const; 38 39 void NodeRegistered(); 40 41 void BufferReceived(BBuffer * buffer); 42 43 status_t GetNextInput(int32 *cookie, media_input *out_input); 44 void DisposeInputCookie(int32 cookie); 45 46 status_t HandleMessage( 47 int32 message, 48 const void *data, 49 size_t size); 50 51 void HandleEvent( 52 const media_timed_event *event, 53 bigtime_t lateness, 54 bool realTimeEvent); 55 56 status_t AcceptFormat( 57 const media_destination &dst, 58 media_format *format); 59 60 void ProducerDataStatus( 61 const media_destination &dst, 62 int32 status, 63 bigtime_t at_media_time); 64 65 status_t GetLatencyFor( 66 const media_destination &dst, 67 bigtime_t *out_latency, 68 media_node_id *out_id); 69 70 status_t Connected( 71 const media_source &src, 72 const media_destination &dst, 73 const media_format &format, 74 media_input *out_input); 75 76 void Disconnected( 77 const media_source &src, 78 const media_destination &dst); 79 80 status_t FormatChanged( 81 const media_source &src, 82 const media_destination &dst, 83 int32 from_change_count, 84 const media_format &format); 85 86 void HandleBuffer(BBuffer *buffer); 87 status_t CreateBuffers(BRect frame, color_space cspace, bool overlay); 88 void DeleteBuffers(); 89 90 private: 91 void _InitDisplay(); 92 VideoWindow * fWindow; 93 VideoView * fVideoView; 94 media_input fInput; 95 bool fOverlayEnabled; 96 bool fOverlayActive; 97 bool fDirectOverlayBuffer; // If the overlay memory is directly written by the producer node. 98 BBitmap * fBitmap; 99 BLocker * fBitmapLocker; 100 BMediaAddOn* fAddOn; 101 int32 fInternalFlavorId; 102 }; 103 104 #endif 105