|
向通道里写数据的代码:
// typedef struct _BVCSP_VideoCodec
// {
// SAVCodec_ID codec; // 编码方式 SAVCODEC_ID_H264、SAVCODEC_ID_H265
// int iWidth; // 视频图像宽度。单位像素
// int iHeight; // 视频图像高度。单位像素
// char* pExtraData; //sps/pps/vps等打包的h264/h265帧数据(含0x00000001头)
// int iExtraDataSize; // pExtraData数据长度
// } BVCSP_VideoCodec;
static void* writeVideoData(void* arg) {
// getMGBvcsp()->dialog_param->szMyselfVideo.codec=SAVCODEC_ID_H265;
// getMGBvcsp()->dialog_param->szMyselfVideo.iWidth=1280;
// getMGBvcsp()->dialog_param->szMyselfVideo.iHeight=720;
int currentSize =0;
BVCSP_Packet packet;
memset(&packet, 0, sizeof(packet));
while(getMGBvcsp()->isOpenSession){
if(currentSize!=getMGBvcsp()->videoSize){
// getMGBvcsp()->dialog_param->szMyselfVideo.pExtraData = reinterpret_cast<char*>(getMGBvcsp()->videoData);
// getMGBvcsp()->dialog_param->szMyselfVideo.iExtraDataSize = getMGBvcsp()->videoSize;
packet.iDataType = BVCSP_DATA_TYPE_VIDEO;
packet.iDataSize = getMGBvcsp()->videoSize;
packet.pData = getMGBvcsp()->videoData;
BVCU_Result result = BVCSP_Dialog_Write(getMGBvcsp()->bvhDialog, &packet);
LOGD("BVCSP_Dialog_Write writeVideoData,BVCU_Result=%d ,videoSize=%d", result,getMGBvcsp()->videoSize);
currentSize=getMGBvcsp()->videoSize;
}
usleep(10000);
}
pthread_exit (NULL);
if (getMGBvcsp()->thr[0] != 0) {
pthread_join(getMGBvcsp()->thr[0], NULL);
}
}
// typedef struct _BVCSP_AudioCodec
// {
// SAVCodec_ID codec; // 编码方式 SAVCODEC_ID_G726、SAVCODEC_ID_AAC
// int iBitrate; // 波特率 32000、16000
// int iChannelCount; // 声道数 1
// int iSampleRate; // 采样率 8000
// SAV_SampleFormat eSampleFormat; // 采样精度 SAV_SAMPLE_FMT_S16
// char* pExtraData; // config字段解出的二进制数据(AAC音频编码时config有意义)。
// int iExtraDataSize; // pExtraData数据长度
// } BVCSP_AudioCodec;
static void* writeAudioData(void* arg) {
// getMGBvcsp()->dialog_param->szMyselfAudio.codec = SAVCODEC_ID_AAC;
// getMGBvcsp()->dialog_param->szMyselfAudio.iBitrate = 16000;
// getMGBvcsp()->dialog_param->szMyselfAudio.iChannelCount = 2;
// getMGBvcsp()->dialog_param->szMyselfAudio.iSampleRate = 16000;
// getMGBvcsp()->dialog_param->szMyselfAudio.eSampleFormat =
// SAV_SAMPLE_FMT_S16;
int currentSize = 0;
BVCSP_Packet packet;
memset(&packet, 0, sizeof(packet));
while (getMGBvcsp()->isOpenSession) {
if (currentSize != getMGBvcsp()->audioSize) {
// getMGBvcsp()->dialog_param->szMyselfAudio.pExtraData =
// reinterpret_cast<char*>(getMGBvcsp()->audioData);
// getMGBvcsp()->dialog_param->szMyselfAudio.iExtraDataSize =
// getMGBvcsp()->audioSize;
BVCSP_Packet packet;
memset(&packet, 0, sizeof(packet));
packet.iDataType = BVCSP_DATA_TYPE_AUDIO;
packet.iDataSize = getMGBvcsp()->audioSize;
packet.pData = getMGBvcsp()->audioData;
BVCU_Result result = BVCSP_Dialog_Write(getMGBvcsp()->bvhDialog, &packet);
LOGD("BVCSP_Dialog_Write writeAudioData,BVCU_Result=%d,audioSize=%d", result,getMGBvcsp()->audioSize);
currentSize=getMGBvcsp()->audioSize;
}
usleep(10000);
}
pthread_exit (NULL);
if (getMGBvcsp()->thr[2] != 0) {
pthread_join(getMGBvcsp()->thr[2], NULL);
}
} |
|