1 /******************************************************************************* 2 / 3 / File: Buffer.h 4 / 5 / Description: A BBuffer is a container of media data in the Media Kit 6 / 7 / Copyright 1997-98, Be Incorporated, All Rights Reserved 8 / 9 *******************************************************************************/ 10 11 #if !defined(_BUFFER_H) 12 #define _BUFFER_H 13 14 #include <MediaDefs.h> 15 16 17 /*** A BBuffer is not the same thing as the area segment that gets cloned ***/ 18 /*** For each buffer that gets created, a BBuffer object is created to represent ***/ 19 /*** it in each participant address space. ***/ 20 21 22 struct _shared_buffer_list; 23 24 struct buffer_clone_info { 25 buffer_clone_info(); 26 ~buffer_clone_info(); 27 media_buffer_id buffer; 28 area_id area; 29 size_t offset; 30 size_t size; 31 int32 flags; 32 private: 33 uint32 _reserved_[4]; 34 }; 35 36 37 class BBuffer 38 { 39 public: 40 41 void * Data(); /* returns NULL if buffer not correctly initialized */ 42 size_t SizeAvailable(); // total size of buffer (how much data can it hold) 43 size_t SizeUsed(); // how much was written (how much data does it hold) 44 void SetSizeUsed( 45 size_t size_used); 46 uint32 Flags(); 47 48 void Recycle(); 49 buffer_clone_info CloneInfo() const; 50 51 media_buffer_id ID(); /* 0 if not registered */ 52 media_type Type(); 53 media_header * Header(); 54 media_audio_header * AudioHeader(); 55 media_video_header * VideoHeader(); 56 57 enum { /* for flags */ 58 B_F1_BUFFER = 0x1, 59 B_F2_BUFFER = 0x2, 60 B_SMALL_BUFFER = 0x80000000 61 }; 62 63 size_t Size(); // deprecated; use SizeAvailable() 64 65 private: 66 67 friend struct _buffer_id_cache; 68 friend struct _shared_buffer_list; 69 friend class BMediaRoster; 70 friend class BBufferProducer; 71 friend class BBufferConsumer; /* for buffer receiving */ 72 friend class BBufferGroup; 73 friend class BSmallBuffer; 74 75 explicit BBuffer(const buffer_clone_info & info); 76 ~BBuffer(); /* BBuffer is NOT a virtual class!!! */ 77 78 BBuffer(); /* not implemented */ 79 BBuffer(const BBuffer & clone); /* not implemented */ 80 BBuffer & operator=(const BBuffer & clone); /* not implemented */ 81 82 void SetHeader(const media_header *header); 83 84 media_header fMediaHeader; 85 _shared_buffer_list * fBufferList; 86 area_id fArea; 87 void * fData; 88 size_t fOffset; 89 size_t fSize; 90 media_buffer_id fBufferID; 91 int32 fFlags; 92 93 uint32 _reserved_buffer_[11]; 94 95 }; 96 97 98 class BSmallBuffer : public BBuffer 99 { 100 public: 101 BSmallBuffer(); 102 103 static size_t SmallBufferSizeLimit(); 104 105 }; 106 107 #endif /* _BUFFER_H */ 108 109