火山 RTC 引擎10 ----远端视频 转网易视频格式
一、
1、原网易视频回调
void onFrameDataCallback(uid_t uid, /**< uid */void *data, /**< 数据指针 */uint32_t type, /**< NERtcVideoType */uint32_t width, /**< 宽度 */uint32_t height, /**< 高度 */uint32_t count, /**< 数据类型个数,即offset及stride的数目 */uint32_t offset[4], /**< 每类数据偏移 */uint32_t stride[4], /**< 每类数据步进 */uint32_t rotation, /**< NERtcVideoRotation */void *user_data /**< 用户透传数据 */){//40267293 刘亚晓 40223353 小黑8Json::Value values;values["account"] = uid;/*bool bAudioMode = false;if (width <= 320)bAudioMode = true;elsebAudioMode = false;std::string im = std::to_string(uid);if (!BExistIm(im) || BAudioModeOfIm(im) != bAudioMode){ResetAudioMode(im, bAudioMode);// 在UI线程中执行更新UI的操作if (uiCallback)uiCallback(uid,bAudioMode);}*/std::string json = values.toStyledString();int64_t time = GetCurTimeStamp();uint32_t size = width * height * 3 / 2;VideoManager::GetInstance()->video_frame_mng_.AddVideoFrame(false, time, (char*)data, size, width, height, json, nim_comp::VideoFrameMng::Ft_I420, false, offset, stride);// VideoManager::GetInstance()->video_frame_mng2_.AddVideoFrame(false, time, (char*)data, size, width, height, json, nim_comp::VideoFrameMng::Ft_I420, false, offset, stride);return;}
2、火山视频格式转网易
bool ChatroomForm::OnFrameDataCallback_ByterRTC(bytertc::IVideoFrame* video_frame){if (!video_frame) return false;bytertc::VideoFrameType type = video_frame->frameType();bytertc::VideoPixelFormat format = video_frame->pixelFormat();bytertc::VideoContentType contentType = video_frame->videoContentType();int width = video_frame->width();int height = video_frame->height();const int planeCount = video_frame->numberOfPlanes();if (planeCount < 3) return false; // I420 需要至少3个planeuint8_t* y_plane = video_frame->getPlaneData(0);uint8_t* u_plane = video_frame->getPlaneData(1);uint8_t* v_plane = video_frame->getPlaneData(2);uint32_t stride[4] = {static_cast<uint32_t>(video_frame->getPlaneStride(0)),static_cast<uint32_t>(video_frame->getPlaneStride(1)),static_cast<uint32_t>(video_frame->getPlaneStride(2)),0};uint8_t* base_ptr = y_plane;uint32_t offset[4] = {0,static_cast<uint32_t>(u_plane - base_ptr),static_cast<uint32_t>(v_plane - base_ptr),0};Json::Value values;values["account"] = "40267293";std::string json = values.toStyledString();int64_t time = GetCurTimeStamp();uint32_t size = width * height * 3 / 2;VideoManager::GetInstance()->video_frame_mng_.AddVideoFrame(false, time, (char*)base_ptr, size, width, height, json, nim_comp::VideoFrameMng::Ft_I420, false, offset, stride);return true;}