22 |
22 |
23 using namespace QTMS; |
23 using namespace QTMS; |
24 using namespace TMS; |
24 using namespace TMS; |
25 |
25 |
26 QTMSMemBuffer::QTMSMemBuffer() |
26 QTMSMemBuffer::QTMSMemBuffer() |
27 { |
27 { |
28 iTmsBuffer = NULL; |
28 iTmsBuffer = NULL; |
29 iOwnsBuffer = FALSE; |
29 iOwnsBuffer = FALSE; |
30 } |
30 } |
31 |
31 |
32 QTMSMemBuffer::~QTMSMemBuffer() |
32 QTMSMemBuffer::~QTMSMemBuffer() |
33 { |
33 { |
34 if (iOwnsBuffer) |
34 if (iOwnsBuffer) { |
35 { |
|
36 free(iDataPtr); |
35 free(iDataPtr); |
37 } |
|
38 } |
36 } |
|
37 } |
39 |
38 |
40 gint QTMSMemBuffer::Create(QTMSBuffer*& buffer, TMS::TMSBuffer*& tmsbuffer) |
39 gint QTMSMemBuffer::Create(QTMSBuffer*& buffer, TMS::TMSBuffer*& tmsbuffer) |
41 { |
40 { |
42 gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY); |
41 gint ret(QTMS_RESULT_INSUFFICIENT_MEMORY); |
43 TRACE_PRN_FN_ENT; |
42 TRACE_PRN_FN_ENT; |
44 QTMSMemBuffer* self = new QTMSMemBuffer(); |
43 QTMSMemBuffer* self = new QTMSMemBuffer(); |
45 if (self) |
44 if (self) { |
46 { |
|
47 self->iTmsBuffer = tmsbuffer; |
45 self->iTmsBuffer = tmsbuffer; |
48 tmsbuffer->GetDataPtr(self->iDataPtr); |
46 tmsbuffer->GetDataPtr(self->iDataPtr); |
49 tmsbuffer->GetDataSize(self->iBufferSize); |
47 tmsbuffer->GetDataSize(self->iBufferSize); |
50 tmsbuffer->GetTimeStamp(self->iTimeStamp); |
48 tmsbuffer->GetTimeStamp(self->iTimeStamp); |
51 self->iOwnsBuffer = FALSE; |
49 self->iOwnsBuffer = FALSE; |
52 } |
50 ret = QTMS_RESULT_SUCCESS; |
|
51 } |
53 buffer = self; |
52 buffer = self; |
54 TRACE_PRN_FN_EXT; |
53 TRACE_PRN_FN_EXT; |
55 return ret; |
54 return ret; |
56 } |
55 } |
57 |
56 |
58 gint QTMSMemBuffer::GetType(QTMSBufferType& buffertype) |
57 gint QTMSMemBuffer::GetType(QTMSBufferType& buffertype) |
59 { |
58 { |
60 gint ret(TMS_RESULT_SUCCESS); |
59 gint ret(TMS_RESULT_SUCCESS); |
61 buffertype = QTMS_BUFFER_MEMORY; |
60 buffertype = QTMS_BUFFER_MEMORY; |
62 return ret; |
61 return ret; |
63 } |
62 } |
64 |
63 |
65 /** |
64 /** |
66 * Gets the timestamp on the Buffer so that the framework can |
65 * Gets the timestamp on the Buffer so that the framework can |
67 * determine the time at which this buffer has to be rendered |
66 * determine the time at which this buffer has to be rendered |
68 * by the output device sink. |
67 * by the output device sink. |
69 * |
68 * |
70 * @param ts timestamp in microseconds |
69 * @param ts timestamp in microseconds |
71 * |
70 * |
72 */ |
71 */ |
73 gint QTMSMemBuffer::GetTimeStamp(guint64& ts) |
72 gint QTMSMemBuffer::GetTimeStamp(guint64& ts) |
74 { |
73 { |
75 gint ret(QTMS_RESULT_SUCCESS); |
74 gint ret(QTMS_RESULT_SUCCESS); |
76 ts = iTimeStamp; |
75 ts = iTimeStamp; |
77 return ret; |
76 return ret; |
78 } |
77 } |
79 |
78 |
80 /** |
79 /** |
81 * Sets the timestamp on the Buffer so that the framework can |
80 * Sets the timestamp on the Buffer so that the framework can |
82 * determine the time at which this buffer has to be rendered |
81 * determine the time at which this buffer has to be rendered |
83 * by the output device sink. |
82 * by the output device sink. |
84 * |
83 * |
85 * @param ts timestamp in milliseconds |
84 * @param ts timestamp in milliseconds |
86 * |
85 * |
87 */ |
86 */ |
88 gint QTMSMemBuffer::SetTimeStamp(const guint64 ts) |
87 gint QTMSMemBuffer::SetTimeStamp(const guint64 ts) |
89 { |
88 { |
90 gint ret(QTMS_RESULT_SUCCESS); |
89 gint ret(QTMS_RESULT_SUCCESS); |
91 iTimeStamp = ts; |
90 iTimeStamp = ts; |
92 ret = iTmsBuffer->SetTimeStamp(ts); |
91 ret = iTmsBuffer->SetTimeStamp(ts); |
93 return ret; |
92 return ret; |
94 } |
93 } |
95 |
94 |
96 /** |
95 /** |
97 * Gets the size of data in the buffer specified by the client. |
96 * Gets the size of data in the buffer specified by the client. |
98 * |
97 * |
99 * @param size size of data in bytes |
98 * @param size size of data in bytes |
100 * |
99 * |
101 */ |
100 */ |
102 gint QTMSMemBuffer::GetDataSize(guint& size) |
101 gint QTMSMemBuffer::GetDataSize(guint& size) |
103 { |
102 { |
104 gint ret(QTMS_RESULT_SUCCESS); |
103 gint ret(QTMS_RESULT_SUCCESS); |
105 size = iBufferSize; |
104 size = iBufferSize; |
106 return ret; |
105 return ret; |
107 } |
106 } |
108 |
107 |
109 /** |
108 /** |
110 * Sets the size of data in the buffer after the client fill it. |
109 * Sets the size of data in the buffer after the client fill it. |
111 * |
110 * |
112 * @param size size of data in bytes |
111 * @param size size of data in bytes |
113 * |
112 * |
114 */ |
113 */ |
115 gint QTMSMemBuffer::SetDataSize(const guint size) |
114 gint QTMSMemBuffer::SetDataSize(const guint size) |
116 { |
115 { |
117 gint ret(QTMS_RESULT_SUCCESS); |
116 gint ret(QTMS_RESULT_SUCCESS); |
118 ret = iTmsBuffer->SetDataSize(size); |
117 ret = iTmsBuffer->SetDataSize(size); |
119 iBufferSize = size; //TODO: should realloc when new size > old size (?) |
118 iBufferSize = size; //TODO: should realloc when new size > old size (?) |
120 return ret; |
119 return ret; |
121 } |
120 } |
122 |
121 |
123 /** |
122 /** |
124 * Gets the pointer to the memory location associated with this |
123 * Gets the pointer to the memory location associated with this |
125 * buffer where the data is stored. |
124 * buffer where the data is stored. |
126 * |
125 * |
127 * @param bufptr ptr to the data stored in the buffer. |
126 * @param bufptr ptr to the data stored in the buffer. |
128 * |
127 * |
129 */ |
128 */ |
130 gint QTMSMemBuffer::GetDataPtr(guint8*& bufptr) |
129 gint QTMSMemBuffer::GetDataPtr(guint8*& bufptr) |
131 { |
130 { |
132 gint ret(QTMS_RESULT_SUCCESS); |
131 gint ret(QTMS_RESULT_SUCCESS); |
133 bufptr = iDataPtr; |
132 bufptr = iDataPtr; |
134 return ret; |
133 return ret; |
135 } |
134 } |
136 |
135 |