|
c代码实例
- int MyImemGetCallback (void *data,
- const char *cookie,
- int64_t *dts,
- int64_t *pts,
- unsigned *flags,
- size_t * bufferSize,
- void ** buffer)
- {
- static int64_t _dts = 0, _pts = 0;
- if (!g_isInit){
- /*load local file*/
- local = fopen(TestFile,"rb");
- if (!local){
- return true;
- }
- size_t count = fread(in_buffer,1,IMG_WIDTH*IMG_HEIGHT*4,local);
- *bufferSize = count;
- *buffer = in_buffer;
- g_isInit = true;
- *dts = _dts; *pts = _pts;
- _dts+=30; _pts+=30;
- return 0 ;
- }
- size_t count = fread(in_buffer,1,IMG_WIDTH*IMG_HEIGHT*4,local);
- *bufferSize = count;
- *buffer = in_buffer;
- *dts = _dts; *pts = _pts;
- _dts+=30; _pts+=30;
- if(count>0) {
- printf("read %d bytes\n",count);
- return 0;
- }else{
- return true; /*eof*/
- }
- }
复制代码
代码说明:
- \param[in] data Pointer to user-defined data, this is your data that
- you set by passing the "--imem-data=<memory_address>" option when
- initializing VLC instance.
- \param[in] cookie A user defined string. This works the same way as
- data, but for string. You set it by adding the "--imem-cookie=<your_string>"
- option when you initialize VLC. Use this when multiple VLC instances are
- running.
- \param[out] dts The decode timestamp, value is in microseconds. This value
- is the time when the frame was decoded/generated. For example, 30 fps
- video would be every 33 ms, so values would be 0, 33333, 66666, 99999, etc.
- \param[out] pts The presentation timestamp, value is in microseconds. This
- value tells the receiver when to present the frame. For example, 30 fps
- video would be every 33 ms, so values would be 0, 33333, 66666, 99999, etc.
- \param[out] flags Unused,ignore.
- \param[out] bufferSize Use this to set the size of the buffer in bytes.
- \param[out] buffer Change to point to your encoded frame/audio/video data.
- The codec format of the frame is user defined and set using the
- "--imem-codec=<four_letter>," where 4 letter is the code for your
- codec of your source data.
复制代码 请教后边4个参数写入数据 是这样的形式吗?
MyImemGetCallback = function(data,cookie,dts,pts,flags,bufferSize,buffer){
::CopyMemoryByStruct(dts,{long dts = 30},8)
::CopyMemoryByStruct(pts,{long pts = 30},8)
::CopyMemoryByStruct(bufferSize,{int pos = #s},4)
::CopyMemoryByStruct(buffer,{string x = s},4)
}
|
|