1 /* 2 * Copyright (c) 2004-2007 Marcus Overhagen <marcus@overhagen.de> 3 * 4 * Permission is hereby granted, free of charge, to any person 5 * obtaining a copy of this software and associated documentation 6 * files (the "Software"), to deal in the Software without restriction, 7 * including without limitation the rights to use, copy, modify, 8 * merge, publish, distribute, sublicense, and/or sell copies of 9 * the Software, and to permit persons to whom the Software is 10 * furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 * OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 25 #ifndef __VIDEO_NODE_H_ 26 #define __VIDEO_NODE_H_ 27 28 #include <BufferConsumer.h> 29 #include <MediaEventLooper.h> 30 31 class VideoView; 32 33 class VideoNode : public BMediaEventLooper, public BBufferConsumer 34 { 35 public: 36 VideoNode(const char *name, VideoView *view); 37 ~VideoNode(); 38 39 void SetOverlayEnabled(bool yesno); 40 bool IsOverlayActive(); 41 42 void LockBitmap(); 43 BBitmap * Bitmap(); 44 void UnlockBitmap(); 45 46 protected: 47 BMediaAddOn * AddOn(int32 *internal_id) const; 48 49 void NodeRegistered(); 50 51 void BufferReceived(BBuffer * buffer); 52 53 status_t GetNextInput(int32 *cookie, media_input *out_input); 54 void DisposeInputCookie(int32 cookie); 55 56 status_t HandleMessage( 57 int32 message, 58 const void *data, 59 size_t size); 60 61 void HandleEvent( 62 const media_timed_event *event, 63 bigtime_t lateness, 64 bool realTimeEvent); 65 66 status_t AcceptFormat( 67 const media_destination &dst, 68 media_format *format); 69 70 void ProducerDataStatus( 71 const media_destination &dst, 72 int32 status, 73 bigtime_t at_media_time); 74 75 status_t GetLatencyFor( 76 const media_destination &dst, 77 bigtime_t *out_latency, 78 media_node_id *out_id); 79 80 status_t Connected( 81 const media_source &src, 82 const media_destination &dst, 83 const media_format &format, 84 media_input *out_input); 85 86 void Disconnected( 87 const media_source &src, 88 const media_destination &dst); 89 90 status_t FormatChanged( 91 const media_source &src, 92 const media_destination &dst, 93 int32 from_change_count, 94 const media_format &format); 95 96 protected: 97 void HandleBuffer(BBuffer *buffer); 98 status_t CreateBuffers(BRect frame, color_space cspace, bool overlay); 99 void DeleteBuffers(); 100 101 protected: 102 VideoView * fVideoView; 103 media_input fInput; 104 bool fOverlayEnabled; 105 bool fOverlayActive; 106 bool fDirectOverlayBuffer; // If the overlay memory is directly written by the producer node. 107 BBitmap * fBitmap; 108 BLocker * fBitmapLocker; 109 }; 110 111 #endif 112