火山RTC 5 转推CDN 布局合成规则
实时音视频房间,转推CDN,文档:
转推直播--实时音视频-火山引擎
一、转推CDN
0、前提
* + 在调用该接口前,你需要在[控制台](https://console.volcengine.com/rtc/workplaceRTC)开启转推直播功能。<br>
* + 调用该方法后,关于启动结果和推流过程中的错误,会收到 onMixingEvent{@link #IMixedStreamObserver#onMixingEvent} 回调。<br>
(我测试的时候,使用的别的平台的CDN 地址,好像不开启,也能转推上去 )
最多合并17路流
https://www.volcengine.com/docs/6348/69850
1、startPushMixedStreamToCDN
1)、接口
/*** @locale zh* @valid since 3.52* @hidden(Linux) not available* @type api* @region 多房间* @brief 新增合流转推直播任务,并设置合流的图片、视频视图布局和音频属性。 <br>* 同一个任务中转推多路直播流时,SDK 会先将多路流合成一路流,然后再进行转推。* @param task_id 转推直播任务 ID,长度不超过 126 字节。<br>* 你可以在同一房间内发起多个转推直播任务,并用不同的任务 ID 加以区分。当你需要发起多个转推直播任务时,应使用多个 ID;当你仅需发起一个转推直播任务时,建议使用空字符串。* @param config 转推直播配置参数。参看 IMixedStreamConfig{@link #IMixedStreamConfig}。* @param observer 端云一体转推直播观察者。参看 IMixedStreamObserver{@link #IMixedStreamObserver}。 <br>* 通过注册 observer 接收转推直播相关的回调。* @return * + 0: 成功<br>* + !0: 失败* @note * + 在调用该接口前,你需要在[控制台](https://console.volcengine.com/rtc/workplaceRTC)开启转推直播功能。<br>* + 调用该方法后,关于启动结果和推流过程中的错误,会收到 onMixingEvent{@link #IMixedStreamObserver#onMixingEvent} 回调。<br>* + 如果已在[控制台](https://console.volcengine.com/rtc/cloudRTC?tab=callback)配置了转推直播的服务端回调,调用本接口会收到 [TranscodeStarted](https://www.volcengine.com/docs/6348/75125#transcodestarted)。重复调用该接口时,第二次调用会同时触发 [TranscodeStarted](https://www.volcengine.com/docs/6348/75125#transcodestarted) 和 [TranscodeUpdated](https://www.volcengine.com/docs/6348/75125#transcodeupdated)。<br>* + 调用 stopPushStreamToCDN{@link #IRTCVideo#stopPushStreamToCDN} 停止转推直播。*//*** @locale en* @valid since 3.52* @hidden(Linux) not available* @type api* @region Multi-room* @brief Create a new task of pushing mixed media streams to CDN and sets the relevant configurations. <br>* When pushing more than one live streams in the same task, SDK will first mix those streams into one single stream and then push it to CDN.* @param task_id Task ID. The length should not exceed 126 bytes.<br>* You may want to push more than one mixed stream to CDN from the same room. When you do that, use different ID for corresponding tasks; if you will start only one task, use an empty string.* @param config Configurations to be set when pushing streams to CDN. See IMixedStreamConfig{@link #IMixedStreamConfig}.* @param observer Register this observer to receive callbacks from the SDK. See IMixedStreamObserver{@link #IMixedStreamObserver}.* @return * + 0: Success<br>* + !0: Failure* @note * + Before calling this API,you need to enable Push to CDN on the [console](https://console.byteplus.com/rtc/workplaceRTC). <br>* + After calling this API, you will be informed of the result and errors during the pushing process via the onMixingEvent{@link #IMixedStreamObserver#onMixingEvent} callback.<br>* + If you have subscribed to the push-to-CDN server callback in the [console](https://console.byteplus.com/rtc/cloudRTC?tab=callback), calling this API will receive a [TranscodeStarted](https://docs.byteplus.com/en/byteplus-rtc/docs/75125#transcodestarted) server callback notification. When calling this API repeatedly, subsequent calls to this API will trigger both [TranscodeStarted](https://docs.byteplus.com/en/byteplus-rtc/docs/75125#transcodestarted) and [TranscodeUpdated](https://docs.byteplus.com/en/byteplus-rtc/docs/75125#transcodeupdated) callbacks.<br>* + Call stopPushStreamToCDN{@link #IRTCVideo#stopPushStreamToCDN} to stop pushing streams to CDN.*/virtual int startPushMixedStreamToCDN(const char* task_id, IMixedStreamConfig* config, IMixedStreamObserver* observer) = 0;
2)、IMixedStreamConfig 合流布局参数
config 转推直播配置参数。
/*** @locale zh* @type keytype* @brief 转推直播配置参数。(新)*/
/*** @locale en* @type keytype* @brief Configurations to be set while pushing media streams to CDN.(New)*/
class IMixedStreamConfig : public ITranscoderParamBase {
public:/*** @locale zh* @type api* @region 转推直播* @brief 获取合流类型。* @return 合流类型,参看 MixedStreamType{@link #MixedStreamType}*//*** @locale en* @type api* @region Push to CDN* @brief Gets the stream mixing type.* @return Stream mixing type. See MixedStreamType{@link #MixedStreamType}*/virtual MixedStreamType getExpectedMixingType() = 0;/*** @locale zh* @type api* @brief 获取推流用户 ID。* @return 推流用户 ID。*//*** @locale en* @type api* @brief Gets the user ID for mixed stream.* @return The user ID for live mixed stream.*/virtual const char* getUserID() = 0;/*** @locale zh* @type api* @brief 获取推流 CDN 地址。* @return 推流地址。*//*** @locale en* @type api* @brief Gets the URL for live mixed stream.* @return The CDN url.*/virtual const char* getPushURL() = 0;/*** @locale zh* @type api* @region 转推直播* @brief 获取用户配置的额外信息。* @return UserConfigExtraInfo 信息。*//*** @locale en* @type api* @region Forward to live broadcast* @brief Get user config extra information.* @return extraI Information.*/virtual const char* getUserConfigExtraInfo() = 0;/*** @locale zh* @type api* @region 转推直播* @brief 获取合流音频参数。* @return 合流音频参数内容,参看 MixedStreamAudioConfig{@link #MixedStreamAudioConfig}。*//*** @locale en* @type api* @region Push to CDN* @brief Gets the audio configurations.* @return Audio configurations. See MixedStreamAudioConfig{@link #MixedStreamAudioConfig}.*/virtual MixedStreamAudioConfig getAudioConfig() = 0;/*** @locale zh* @type api* @region 转推直播* @brief 获取合流视频转码参数。* @return 合流视频转码参数内容,参看 MixedStreamVideoConfig{@link #MixedStreamVideoConfig}。*//*** @locale en* @type api* @region Push to CDN* @brief Gets the video configurations.* @return Video configurations. See MixedStreamVideoConfig{@link #MixedStreamVideoConfig}.*/virtual MixedStreamVideoConfig getVideoConfig() = 0;/*** @locale zh* @hidden(Windows,macOS,Linux)* @type api* @brief 获取转推 CDN 时的空间音频参数。* @return 参看 MixedStreamSpatialAudioConfig{@link #MixedStreamSpatialAudioConfig}。*//*** @locale en* @hidden(Windows,macOS,Linux)* @type api* @brief Get the spatial audio configurations of pushing to CDN.* @return See MixedStreamSpatialAudioConfig{@link #MixedStreamSpatialAudioConfig}.*/virtual MixedStreamSpatialAudioConfig getSpatialAudioConfig() = 0;/*** @locale zh* @type api* @region 转推直播* @brief 获取合流视窗布局信息。* @param index 视窗对应下标。* @return 合流视窗布局信息,参看 MixedStreamLayoutRegionConfig{@link #MixedStreamLayoutRegionConfig}。*//*** @locale en* @type api* @region Push to CDN* @brief Gets the video layout information of the mixed stream.* @param index The number of the view of which you want to get information.* @return Layout information. See MixedStreamLayoutRegionConfig{@link #MixedStreamLayoutRegionConfig}.*/virtual MixedStreamLayoutRegionConfig getLayoutByIndex(int32_t index) = 0;/*** @locale zh* @hidden for internal use only* @type api* @region 转推直播* @brief 获取动态扩展自定义参数* @return 动态扩展自定义参数*//*** @locale en* @hidden for internal use only* @type api* @region Forward to live broadcast* @brief Get dynamically extend customizable parameters* @return dynamically extend customizable parameters*/virtual const char* getAdvancedConfig() = 0;/*** @locale zh* @hidden for internal use only* @type api* @region 转推直播* @brief 获取业务透传鉴权信息* @return 业务透传鉴权信息*//*** @locale en* @hidden for internal use only* @type api* @region Forward to live broadcast* @brief Get Business Transparent Authentication Information* @return Business Transparent Authentication Information*/virtual const char* getAuthInfo() = 0;/*** @locale zh* @type api* @brief 获取客户端合流信息。* @return 客户端合流信息,参看 MixedStreamClientMixConfig{@link #MixedStreamClientMixConfig}。*//*** @locale en* @type api* @brief Get client mixing parameters.* @return Client mixing parameters. See MixedStreamClientMixConfig{@link #MixedStreamClientMixConfig}.*/virtual MixedStreamClientMixConfig getClientMixConfig() = 0;/*** @locale zh* @hidden for internal use only* @type api* @brief 获取转推直播同步参数。* @return 转推直播同步参数,参看 MixedStreamSyncControlConfig{@link #MixedStreamSyncControlConfig}。*//*** @locale en* @hidden for internal use only* @type api* @brief Get transcoding sync control parameters.* @return Transcoding sync control parameters. See MixedStreamSyncControlConfig{@link #MixedStreamSyncControlConfig}.*/virtual MixedStreamSyncControlConfig getSyncControlConfig() = 0;/*** @locale zh* @type api* @region 转推直播* @brief 设置合流类型。建议设置。* @param expected_mix_type 合流类型,参看 MixedStreamType{@link #MixedStreamType}*//*** @locale en* @type api* @region Push to CDN* @brief Sets the expected stream mixing type. It's recommended to be set.* @param expected_mix_type Stream mixing type. See MixedStreamType{@link #MixedStreamType}*/virtual void setExpectedMixingType(MixedStreamType expected_mix_type) = 0;/*** @locale zh* @type api* @brief 设置推流用户 ID。`room_id` 和 `user_id` 长度相加不得超过 126 字节。建议设置。<br>* 本参数不支持过程中更新。* @param user_id 推流用户 ID。*//*** @locale en* @type api* @brief Sets the user ID for live transcoding. The sum length of `room_id` and `user_id` should not exceed 126 bytes. It's recommended to be set.<br>* This parameter cannot be updated while pushing stream to the CDN.* @param user_id The user ID for live transcoding.*/virtual void setUserID(const char* user_id) = 0;/*** @locale zh* @type api* @brief 设置推流 CDN 地址。仅支持 RTMP 协议,Url 必须满足正则 `/^rtmps?:\/\//`。建议设置。<br>* 本参数不支持过程中更新。* @param url 推流地址。*//*** @locale en* @type api* @brief Sets the URL for live transcoding. Only supports live transcoding via RTMP. The URL should match the regular expression `/^rtmps?:\/\//`. It's recommended to be set.<br>* This parameter cannot be updated while pushing stream to the CDN.* @param url The URL to be set.*/virtual void setPushURL(const char* push_url) = 0;/*** @locale zh* @type api* @region 转推直播* @brief 设置音频参数。参看 MixedStreamAudioConfig{@link #MixedStreamAudioConfig}。建议设置。<br>* 本参数不支持过程中更新。*//*** @locale en* @type api* @region Push to CDN* @brief Sets audio configurations. See MixedStreamAudioConfig{@link #MixedStreamAudioConfig}. It's recommended to be set.<br>* This parameters cannot be updated while pushing stream to the CDN.*/virtual void setAudioConfig(const MixedStreamAudioConfig&) = 0;/*** @locale zh* @type api* @region 转推直播* @brief 设置视频参数。参看 MixedStreamVideoConfig{@link #MixedStreamVideoConfig}。建议设置。*//*** @locale en* @type api* @region Push to CDN* @brief Sets video configurations. See MixedStreamVideoConfig{@link #MixedStreamVideoConfig}. It's recommended to be set.*/virtual void setVideoConfig(const MixedStreamVideoConfig&) = 0;/*** @locale zh* @hidden(Windows,macOS,Linux)* @type api* @brief 设定转推 CDN 时的空间音频效果。参看 MixedStreamSpatialAudioConfig{@link #MixedStreamSpatialAudioConfig}。*//*** @locale en* @hidden(Windows,macOS,Linux)* @type api* @brief Sets spatial audio configurations. See MixedStreamSpatialAudioConfig{@link #MixedStreamSpatialAudioConfig}.*/virtual void setSpatialAudioConfig(const MixedStreamSpatialAudioConfig&) = 0;/*** @locale zh* @type api* @region 转推直播* @brief 设置视频流合流整体布局信息。* @param regions[] 用户布局信息列表。为 MixedStreamLayoutRegionConfig{@link #MixedStreamLayoutRegionConfig} 数据类型的数组。每一个该类型对象为一路单独的视频流的布局信息。<br>* 值不合法或未设置时,自动使用默认值。建议设置。* @param regions_size 合流视窗数量。建议设置。* @param background_color 合流背景颜色,用十六进制颜色码(HEX)表示。例如,#FFFFFF 表示纯白,#000000 表示纯黑。默认值为 #000000。建议设置。<br>* 值不合法或未设置时,自动使用默认值。* @param user_extra_info 透传的 App 数据。*//*** @locale en* @type api* @region Push to CDN* @brief Sets the layout configurations.* @param regions[] User layout information list. It's a list of MixedStreamLayoutRegionConfig{@link #MixedStreamLayoutRegionConfig} that you construct for each stream.<br>* With invalid or empty input, the configurations will be set as the default values. It's recommended to be set.* @param regions_size Amount of views. It's recommended to be set.* @param background_color Background-color of the mixed stream in hexadecimal values such as #FFFFFF and #000000. The default value is #000000. It's recommended to be set.<br>* With invalid or empty input, the configurations will be set as the default values.* @param user_extra_info Additional data that you want to import.*/virtual void setLayoutConfig(MixedStreamLayoutRegionConfig regions[],int32_t regions_size,const char* background_color,const char* user_extra_info) = 0;/*** @locale zh* @hidden for internal use only* @type api* @region 转推直播* @brief 设置动态扩展自定义参数* @param advanced_config 动态扩展自定义参数*//*** @locale en* @hidden for internal use only* @type api* @region Forward to live broadcast* @brief Sets dynamically extend customizable parameters* @param advanced_config dynamically extend customizable parameters*/virtual void setAdvancedConfig(const char* advanced_config) = 0;/*** @locale zh* @hidden for internal use only* @type api* @region 转推直播* @brief 设置业务透传鉴权信息* @param auth_info 业务透传鉴权信息*//*** @locale en* @hidden for internal use only* @type api* @region Forward to live broadcast* @brief Sets Business Transparent Authentication Information* @param auth_info Business Transparent Authentication Information*/virtual void setAuthInfo(const char* auth_info) = 0;/*** @locale zh* @type api* @brief 设置客户端合流信息,参看 MixedStreamClientMixConfig{@link #MixedStreamClientMixConfig}。*//*** @locale en* @type api* @brief Sets client mixing parameters. See MixedStreamClientMixConfig{@link #MixedStreamClientMixConfig}.*/virtual void setClientMixConfig(MixedStreamClientMixConfig&) = 0;/*** @locale zh* @hidden for internal use only* @type api* @brief 设置转推直播同步参数。参看 MixedStreamSyncControlConfig{@link #MixedStreamSyncControlConfig}。*//*** @locale en* @hidden for internal use only* @type api* @brief Sets transcoding sync control parameters. See MixedStreamSyncControlConfig{@link #MixedStreamSyncControlConfig}.*/virtual void setSyncControlConfig(MixedStreamSyncControlConfig&) = 0;/*** @locale zh* @type api* @brief 获取服务端合流控制参数。参看 MixedStreamServerControlConfig{@link #MixedStreamServerControlConfig}。*//*** @locale en* @type api* @brief Gets the configurations while mixing streams on the server side. See MixedStreamServerControlConfig{@link #MixedStreamServerControlConfig}.*/virtual MixedStreamServerControlConfig getServerControlConfig() = 0;/*** @locale zh* @type api* @brief 设置服务端合流控制参数。参看 MixedStreamServerControlConfig{@link #MixedStreamServerControlConfig}。*//*** @locale en* @type api* @brief Sets the configurations while mixing streams on the server side. See MixedStreamServerControlConfig{@link #MixedStreamServerControlConfig}.*/virtual void setServerControlConfig(MixedStreamServerControlConfig& config) = 0;/*** @locale zh* @valid since 3.57* @type api* @brief 设置合流后整体画布的背景图片 URL,长度最大为 1024 bytes。<br>* 支持的图片格式包括:JPG, JPEG, PNG。如果背景图片的宽高和整体屏幕的宽高不一致,背景图片会缩放到铺满屏幕。*//*** @locale en* @valid since 3.57* @type api* @brief Sets the URL of the background image for the canvas that renders the mixed stream, with a maximum length of 1024 bytes.<br>* You can input images in the following supported formats: JPG, JPEG, PNG.<br>* If the width and height of the background image are different from the screen dimensions, the background image will be scaled to fill the screen.*/virtual void setBackgroundImageURL(const char* background_image_url) = 0;/*** @locale zh* @valid since 3.57* @type api* @brief 获取背景图片的地址。*//*** @locale en* @type api* @brief Gets the background image URL.*/virtual const char* getBackgroundImageURL() = 0;/*** @locale zh* @hidden for internal use only* @type api* @region 转推直播* @brief 将输入的 json 格式的字符串转成 ITranscoderParam 结构体* @param json_str json 格式字符串* @return 转换后的 ITranscoderParam 结构体*//*** @locale en* @hidden for internal use only* @type api* @region Push to CDN* @brief Convert the json format string into the ITranscoderParam structure* @param json_str Json format string* @return Converted ITranscoderParam structure*/virtual IMixedStreamConfig* inflatten(const char* json_str) = 0;/*** @locale zh* @type api* @region 转推直播* @brief 获取默认的合流转推参数* @return 生成的 IMixedStreamConfig 结构体*//*** @locale en* @type api* @region Push to CDN* @brief Get default transcoding config* @return Default IMixedStreamConfig structure*/virtual IMixedStreamConfig* defaultMixedStreamConfig() = 0;/*** @hidden constructor/destructor*/virtual ~IMixedStreamConfig() = default;/*** @hidden for internal use only* @type api*/virtual void setConvertFromOldTranscodeParam(bool is_from_old_param) = 0;/*** @hidden for internal use only* @type api*/virtual bool getIsConvertFromOldTranscodeParam() = 0;
};
3)、IMixedStreamObserver
* @param observer 端云一体转推直播观察者。参看 IMixedStreamObserver{@link #IMixedStreamObserver}。 <br>
* 通过注册 observer 接收转推直播相关的回调。
3.1)、 事件监听 观察者
/*** @locale zh* @type callback* @region 转推直播* @brief 合流推流 Observer<br>* 注意:回调函数是在 SDK 内部线程(非 UI 线程)同步抛出来的,请不要做耗时操作或直接操作 UI,否则可能导致 app 崩溃。*/
/*** @locale en* @type callback* @region Push to CDN* @brief Register this observer to receive stream mixing related callbacks from the SDK.<br>* Note: Callback functions are thrown synchronously in a non-UI thread within the SDK. Therefore, you must not perform any time-consuming operations or direct UI operations within the callback function, as this may cause the app to crash.*/
class IMixedStreamObserver {
public:/*** @locale zh* @type callback* @region 转推直播* @brief 是否具有推流能力。 <br>* + false:不具备推流能力(默认值) <br>* + true:具备推流能力* @note * + 如果需要开启端云一体转推直播功能,你必须确保你的 App 包含 librtmp,具有推流能力。此时,设置该回调为<br>* true。*//*** @locale en* @type callback* @region Push to CDN* @brief Whether your App has the ability to push streams to CDN. <br>* + True: Yes <br>* + False: No (default value)* @note * + If you need to use the function of intelligently pushing streams to CDN, you should ensure that your App<br>* contains librtmp and has the ability to push streams out. If so, set the callback to True.*/virtual bool isSupportClientPushStream() = 0;/*** @locale zh* @hidden(Linux) not available* @type callback* @region 转推直播* @brief 转推直播状态回调* @param event 转推直播任务状态,参看 StreamMixingEvent{@link #StreamMixingEvent}* @param task_id 转推直播任务 ID* @param error 转推直播错误码,参看 StreamMixingErrorCode{@link #StreamMixingErrorCode}。* @param mix_type 转推直播类型,参看 MixedStreamType{@link #MixedStreamType}*//*** @locale en* @hidden(Linux) not available* @type callback* @region Push to CDN* @brief Used for reporting events during pushing streams to CDN* @param event Type Stream mixing status, see StreamMixingEvent{@link #StreamMixingEvent}* @param task_id Task ID* @param error Errors occuring during the pushing process. See StreamMixingErrorCode{@link #StreamMixingErrorCode}* @param mix_type Stream mixing and pushing type. See MixedStreamType{@link #MixedStreamType}*/virtual void onMixingEvent(StreamMixingEvent event, const char* task_id, StreamMixingErrorCode error, MixedStreamType mix_type) = 0;/*** @locale zh* @type callback* @region 转推直播* @brief 合流视频回调,运行在视频回调线程* @param task_id 合流任务 ID* @param video_frame 视频帧,参看 IVideoFrame{@link #IVideoFrame}。* @note 收到该回调的周期与视频的帧间隔一致。*//*** @locale en* @type callback* @region Push to CDN* @brief Callback with the video data after stream mixing, running on the video callback thread* @param task_id Task ID* @param video_frame Video Frame, see IVideoFrame{@link #IVideoFrame}.* @note The interval between callbacks is the same with that between video frames.*/virtual void onMixingVideoFrame(const char* task_id, IVideoFrame* video_frame) = 0;/*** @locale zh* @type callback* @region 转推直播* @brief 合流音频回调,运行在音频回调线程* @param task_id 转推直播任务 ID* @param audio_frame 音频帧,参看 IAudioFrame{@link #IAudioFrame}。* @note 收到该回调的周期为每 10 毫秒一次,并且每次的音频数据量为 10 毫秒数据量。*//*** @locale en* @type callback* @region Push to CDN* @brief Callback with the audio data after stream mixing, running on the audio callback thread* @param task_id Task ID.* @param audio_frame Audio Frame, see IAudioFrame{@link #IAudioFrame}.* @note You will receive the callback every 10 milliseconds. Each callback carries data collected in the last 10<br>* milliseconds.*/virtual void onMixingAudioFrame(const char* task_id, IAudioFrame* audio_frame) = 0;/*** @locale zh* @type callback* @region 转推直播* @brief 视频 SEI 帧回调,运行在视频回调线程* @param task_id 转推直播任务 ID* @param data_frame SEI 数据*//*** @locale en* @type callback* @region Push to CDN* @brief This callback carries SEI data, running on the video callback thread* @param task_id Task ID* @param data_frame SEI data*/virtual void onMixingDataFrame(const char* task_id, IDataFrame* data_frame) = 0;/*** @locale zh* @hidden for internal use only* @type callback* @region 转推直播* @brief 同步视频帧回调。* @param task_id 转推直播任务 ID。* @param uids 同步视频帧对应的 uid 数组。* @param video_frames 同步视频帧数组,与 uids 对应。* @param data_frame SEI 数据。* @param count 数组的长度。*//*** @locale en* @hidden for internal use only* @type callback* @region Push to CDN* @brief Synchronized video frame callback.* @param task_id Task ID.* @param uids Array of synchronized video frames corresponding to uids.* @param video_frames Array of synchronized video frames corresponding to uids.* @param data_frame SEI data.* @param count The length of the array.*/virtual void onCacheSyncVideoFrames(const char* task_id, const char* uids[], IVideoFrame* video_frames[],IDataFrame* data_frame[], int count) = 0;/*** @locale zh* @hidden constructor/destructor* @brief 析构函数*//*** @locale en* @hidden constructor/destructor* @brief Destructor*/virtual ~IMixedStreamObserver() = default;
};
3.2)、示例:
class ByteRTCEventHandler : public QObject,public bytertc::IRTCVideoEventHandler,public bytertc::IAudioEffectPlayerEventHandler,public bytertc::IMixedStreamObserver,public bytertc::IMediaPlayerEventHandler{
std::unique_ptr<ByteRTCEventHandler> m_handler;..............................................................................
..............................................................................//isSupportClientPushStream//return false: 告诉SDK,使用服务端合流方式,即由RTCSDK推到CDN//return true: 告诉SDK,使用业务层转推RTMP能力,需要业务层具备转推到CDN的能力// 本功能展示的是 如何使用RTCSDK 服务器合流,业务层不支持转推CDN,因此需要return false;m_handler.reset(new ByteRTCEventHandler());m_handler->setIsSupportClientPushStream(false); //本Demo使用RTC服务器推流,因此isSupportClientPushStream返回false
connect(m_handler.get(), &ByteRTCEventHandler::sigMixingEvent, this, &CDNStreamByServer::onSigMixingEvent);
m_video = bytertc::createRTCVideo(g_appid.c_str(), m_handler.get(), nullptr);
bytertc::IMixedStreamConfig* mixed_stream_param = getMixedStreamConfig();int ret = m_video->startPushMixedStreamToCDN(m_task.c_str(), mixed_stream_param, m_handler.get());
4)、调用示例:
m_task = "task1";if (ui->lineEdit_url->text().isEmpty()) {QMessageBox box(QMessageBox::Warning, QStringLiteral("提示"), QString("url is empty"), QMessageBox::Ok);box.exec();return;}std::lock_guard<std::recursive_mutex> locker(m_mutex);if (m_video == nullptr) return;bytertc::IMixedStreamConfig* mixed_stream_param = getMixedStreamConfig();int ret = m_video->startPushMixedStreamToCDN(m_task.c_str(), mixed_stream_param, m_handler.get());if (ret != 0) {QMessageBox box(QMessageBox::Warning, QStringLiteral("提示"), QString("startPushMixedStreamToCDN error,请检查是否已经在控制台开通该功能"), QMessageBox::Ok);box.exec();return;}
2、updatePushMixedStreamToCDN
有人员变化时,实时更新合流配置
/*** @locale zh* @valid since 3.52* @hidden(Linux) not available* @type api* @region 多房间* @brief 更新合流转推直播参数,会收到 onMixingEvent{@link #IMixedStreamObserver#onMixingEvent} 回调。 <br>* 使用 startPushMixedStreamToCDN{@link #IRTCVideo#startPushMixedStreamToCDN} 启用转推直播功能后,使用此方法更新功能配置参数。* @param task_id 转推直播任务 ID。指定想要更新参数设置的转推直播任务。* @param config 转推直播配置参数,参看 IMixedStreamConfig{@link #IMixedStreamConfig}。除特殊说明外,均支持过程中更新。<br>* 调用时,结构体中没有传入值的属性,会被更新为默认值。* @return * + 0: 成功<br>* + !0: 失败*//*** @locale en* @valid since 3.52* @hidden(Linux) not available* @type api* @region Multi-room* @brief Update parameters needed when pushing mixed media streams to CDN. You will be informed of the change via the onMixingEvent{@link #IMixedStreamObserver#onMixingEvent} callback. <br>* After calling startPushMixedStreamToCDN{@link #IRTCVideo#startPushMixedStreamToCDN} to enable the function of pushing streams to CDN, you can call this API to update the relevant configurations.* @param task_id Task ID. Specifys of which pushing task you want to update the parameters.* @param config Configurations that you want to update. See IMixedStreamConfig{@link #IMixedStreamConfig} for specific indications. You can update any property for the task unless it is specified as unavailable for updates.<br>* If you left some properties blank, you can expect these properties to be set to their default values.* @return * + 0: Success<br>* + !0: Failure*/virtual int updatePushMixedStreamToCDN(const char* task_id, IMixedStreamConfig* config) = 0;
bytertc::IMixedStreamConfig* config = getMixedStreamConfig();int ret = m_video->updatePushMixedStreamToCDN(m_task.c_str(), config);if (ret != 0) {QMessageBox box(QMessageBox::Warning, QStringLiteral("提示"), QString("updatePushMixedStreamToCDN error,请检查参数"), QMessageBox::Ok);box.exec();return;}
3、getMixedStreamConfig 具体合流配置
音频总体、视频画布总体、每个人的位置/视频适配方式/混流 音频 视频方式
bytertc::IMixedStreamConfig* CDNStreamByServer::getMixedStreamConfig()
{// audiobytertc::MixedStreamAudioConfig audioParam;audioParam.audio_codec = bytertc::MixedStreamAudioCodecType::kMixedStreamAudioCodecTypeAAC;audioParam.channels = ui->comboBox_channel->currentText().toInt();audioParam.bitrate = ui->spinBox_a_bitrate->value();audioParam.sample_rate = ui->comboBox_samplerate->currentText().toInt();audioParam.audio_profile = bytertc::MixedStreamAudioProfile::kMixedStreamAudioProfileLC;// videobytertc::MixedStreamVideoConfig videoParam;videoParam.bitrate = ui->spinBox_v_bitrate->value();videoParam.fps = ui->spinBox_v_fps->value();videoParam.gop = 2;videoParam.width = 640;videoParam.height = 360;videoParam.enable_bframe = false;if (ui->comboBox_v_code->currentText().contains("264")) {videoParam.video_codec = bytertc::kMixedStreamVideoCodecTypeH264; //本参数不支持过程中更新}else {videoParam.video_codec = bytertc::kMixedStreamVideoCodecTypeByteVC1;}// layoutbytertc::MixedStreamLayoutRegionConfig* layouts = new bytertc::MixedStreamLayoutRegionConfig[m_rendered_users.size()];int i = 0;std::map<std::string, UserWidget*>::iterator ite;for (ite = m_rendered_users.begin(); ite != m_rendered_users.end(); ite++) {bytertc::MixedStreamLayoutRegionConfig lay;lay.region_id = ite->first.c_str();lay.room_id = m_roomid.c_str();lay.location_x = (i % 2) * 0.5 * videoParam.width; lay.location_y = (i / 2) * 0.5 * videoParam.height;if (m_rendered_users.size() == 1) {lay.width = 0.8 * videoParam.width; lay.height = 0.8 * videoParam.height;}else if (m_rendered_users.size() == 2) {lay.width = 0.4 * videoParam.width; lay.height = 0.8 * videoParam.height;}else {lay.width = 0.4 * videoParam.width;lay.height = 0.4 * videoParam.height;}if (ite->first == m_localid) {lay.is_local_user = true;}else {lay.is_local_user = false;}lay.alpha = 1.0f;lay.z_order = 0;// 视频适配方式/混流 音频 视频方式 lay.render_mode = bytertc::MixedStreamRenderMode::kMixedStreamRenderModeHidden;lay.stream_type = bytertc::MixedStreamVideoType::kMixedStreamVideoTypeMain;lay.media_type = bytertc::MixedStreamMediaType::kMixedStreamMediaTypeAudioAndVideo;lay.apply_spatial_audio = false;layouts[i++] = lay;}bytertc::MixedStreamClientMixConfig client_conf;client_conf.use_audio_mixer = true;client_conf.video_format = bytertc::kMixedStreamClientMixVideoFormatI420;std::string url = ui->lineEdit_url->text().toStdString();bytertc::IMixedStreamConfig* mixed_stream_param = bytertc::createMixedStreamConfig();mixed_stream_param->setAudioConfig(audioParam);mixed_stream_param->setVideoConfig(videoParam);mixed_stream_param->setLayoutConfig(layouts, m_rendered_users.size(), m_str_color.c_str(), nullptr);mixed_stream_param->setExpectedMixingType(bytertc::kMixedStreamTypeByServer); mixed_stream_param->setPushURL(url.c_str());mixed_stream_param->setRoomID(m_roomid.c_str());mixed_stream_param->setUserID(m_localid.c_str());mixed_stream_param->setClientMixConfig(client_conf);delete[]layouts;return mixed_stream_param;QStringList list = {"setAudioConfig", "setVideoConfig", "setLayoutConfig", "setExpectedMixingType", "setPushURL", "setRoomID", "setUserID", "setClientMixConfig"};appendAPI(list);
}
相关文章:
火山RTC 5 转推CDN 布局合成规则
实时音视频房间,转推CDN,文档: 转推直播--实时音视频-火山引擎 一、转推CDN 0、前提 * 在调用该接口前,你需要在[控制台](https://console.volcengine.com/rtc/workplaceRTC)开启转推直播功能。<br> * 调…...
Mujoco xml < sensor>
< sensor> jointposjointveljointactuatorfrcframequatgyroaccelerometerframeposframelinveltouchobjtype"site" objname"imu" 和site"imu"的区别python中与sensor有关的写法传感器名字索引第几个idid索引传感器名字传感器数量sensor中的…...
示例:spring xml+注解混合配置
以下是一个 Spring XML 注解的混合配置示例,结合了 XML 的基础设施配置(如数据源、事务管理器)和注解的便捷性(如依赖注入、事务声明)。所有业务层代码通过注解简化,但核心配置仍通过 XML 管理。 1. 项目结…...
同样的html标记,不同语言的文本,显示的字体和粗细会不一样吗
同样的 HTML 标记,在不同语言的文本下,显示出来的字体和粗细确实可能会不一样,原因如下: 🌍 不同语言默认字体不同 浏览器字体回退机制 CSS 里写的字体如果当前系统不支持,就会回退到下一个,比如…...
Linux进程6-alarm闹钟定时终止、raise发送信号、abort终止、pause挂起进程验证
目录 1.alarm函数 1.1关键点 1.2单个alarm函数定时 1.3两个alarm函数定时 2.raise函数 2.1核心行为 2.2 raise与 kill 的区别 2.3程序: 3.abort函数 4.pause 函数 4.1 pause简单挂起 4.2父进程挂起,子进程发信号 1.alarm函数 函数原型&…...
SpringCloud组件—Eureka
一.背景 1.问题提出 我们在一个父项目下写了两个子项目,需要两个子项目之间相互调用。我们可以发送HTTP请求来获取我们想要的资源,具体实现的方法有很多,可以用HttpURLConnection、HttpClient、Okhttp、 RestTemplate等。 举个例子&#x…...
类加载器与jvm的内存
1. 类加载器与内存的关系 类加载器的字节码放在方法区(元空间)中,同时类加载器加载类后类的信息(成员变量、成员方法及修饰符等)存放在方法区中。类的信息所占内存的回收要同时满足两个条件:类的实例被回收…...
【C++】新手入门指南(下)
文章目录 前言 一、引用 1.引用的概念和定义 2.引用的特性 3.引用的使用 4.const引用 5.指针和引用的关系 二、内联函数 三、nullptr 总结 前言 这篇续上篇的内容新手入门指南(上),继续带大家学习新知识。如果你感兴趣欢迎订购本专栏。 一、…...
el-table中el-input的autofocus无法自动聚焦的解决方案
需求 有一个表格展示了一些进度信息,进度信息可以修改,需要点击进度信息旁边的编辑按钮时,把进度变为输入框且自动聚焦,当鼠标失去焦点时自动请求更新接口。 注:本例以vue2 element UI为例 分析 这个需求看着挺简单…...
vimplus 如何修改语言支持的版本,以及如何跳转路径
vimplus修改语言版本 默认的vimplus支持c的版本是17 如何修改我们需要修改.ycm_extra_conf.py文件,这个文件管理了我们的插件配置 找到 把他修改为你想要的版本 增添路径 把你安装的gcc位置提供给他,默认的目前比较老 这里都是他提前为我们准备的路…...
麒麟V10安装MySQL8.4
1、下载安装包 wget https://cdn.mysql.com//Downloads/MySQL-8.4/mysql-8.4.5-1.el7.x86_64.rpm-bundle.tar2、解压 mkdir -p /opt/mysql tar -xvf mysql-8.4.5-1.el7.x86_64.rpm-bundle.tar -C /opt/mysql3、安装MySQL 3.1、卸载mariadb rpm -qa | grep mariadb rpm -e m…...
Varjo-XR3在UE5中,头显中间有一个方块一直显示
深色方块显示在屏幕中间的焦点区域中 屏幕中间的对焦区域中显示的黑色方块。 黑色方块是一个已知问题。它在 Varjo VRTemplate 中不可见,因为它使用具有推荐 VR 设置的前向渲染方法。 但是,如果你将延迟渲染方法与高级功能(如 Lumen、Nani…...
FastText 模型文本分类实验:从零到一的实战探索
在自然语言处理(NLP)领域,文本分类是一个基础而重要的任务,广泛应用于情感分析、主题识别、垃圾邮件过滤等多个场景。最近,我参与了一次基于 FastText 模型的文本分类实验,从数据预处理到模型构建、训练和评…...
不同经营性道路运输从业资格证申请条件全解析
在道路运输领域,获取相应的从业资格证是合法从事经营性运输工作的关键前提。不同类型的运输业务,如旅客运输、货物运输以及危险货物运输,对从业者有着不同的条件要求。 经营性道路旅客运输驾驶员 驾驶证年限:需取得相应的机动车…...
WHAT - 静态资源缓存穿透
文章目录 1. 动态哈希命名的基本思路2. 具体实现2.1 Vite/Webpack 配置动态哈希2.2 HTML 文件中动态引用手动引用使用 index.html 模板动态插入 2.3 结合 Cache-Control 避免缓存穿透2.4 适用于多环境的动态策略 总结 在多环境部署中,静态资源缓存穿透是一个常见问题…...
11、Refs:直接操控元素——React 19 DOM操作秘籍
一、元素操控的魔法本质 "Refs是巫师与麻瓜世界的连接通道,让开发者能像操控魔杖般精准控制DOM元素!"魔杖工坊的奥利凡德先生轻抚着魔杖,React/Vue的refs能量在杖尖跃动。 ——以神秘事务司的量子纠缠理论为基,揭示DOM…...
crontab 定时备份 mysql 数据库
1、使用 mysqldump 命令备份数据 1.1 备份全部数据库的数据和结构 mysqldump -uroot -p123456 -A > /data/backup/db.sql1.2 备份全部数据库的结构(加 -d 参数) mysqldump -uroot -p123456 -A -d > /data/backup/db.sql1.3 备份全部数据库的数据…...
数据库对象与权限管理-视图与索引管理
一、视图(View)管理 1. 视图的定义与本质 视图(View)是Oracle数据库中的逻辑表,它不直接存储数据,而是通过预定义的SQL查询动态生成结果集。视图的本质可以理解为: 虚拟表:用户可…...
德施曼重磅发布五大突破性技术及多款重磅新品,开启AI智能管家时代
当智能锁拥抱人文关怀,万物有灵便有了具象化的表达。 4月22日,智能锁领军品牌德施曼“万物有灵”2025全球新品发布会在乌镇隆重举行,为智能锁行业带来了AI时代的革新方案。 会上,德施曼创始人/CEO祝志凌重磅发布了五大突破性技术&…...
单元测试学习笔记(一)
自动化测试 通过测试工具/编程模拟手动测试步骤,全自动半自动执行测试用例,对比预期输出和实际输出,记录并统计测试结果,减少重复的工作量。 单元测试 针对最小的单元测试,Java中就是一个一个的方法就是一个一个的单…...
Rest Client插件写http文件直接发送请求
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言📌 插件介绍:🚀 安装方式:📚 使用示例:⚙️ 功能亮点: 前言 直接在 VSCode …...
LLM 论文精读(一)Scaling Laws for Neural Language Models
这篇文章是2020年发表的一篇LLM领域中非常重要的论文,由OpenAI发布,总结了LLM模型规模与训练数据token之间的比例关系,即我们熟知的 Scaling Laws,允许 通过观察小规模训练实验,提前预测大模型的效果表现,降…...
Spring AOP + Logback + MDC全链路日志追踪
1、背景 由于权限管理和安全规范,服务都部署到云上,只能通过日志系统查看日志。 然而,面对海量的日志数据,如何快速定位关键信息和调用链路是一个巨大的挑战。 2、方案调研 在 Spring Boot 中实现全链路日志追踪,核…...
SVT-AV1编码器初始化函数
一 函数解释 这个函数SVT-AV1编码器初始化的核心函数,负责配置编码器组件,分配资源并启动编码线程,以下时对每一行的详细解释。 函数签名和参数检查 EB_API EbErrorType svt_av1_enc_init(EbComponentType *svt_enc_component) { if (svt_enc…...
Unity 导出Excel表格
1.首先,需要导入EPPlus.dll;(我这里用的是Unity 2017.3.0f3) https://download.csdn.net/download/qq_41603955/90670669 2.代码如下: using UnityEngine; using UnityEditor; using System.IO; using OfficeOpenXm…...
Web前端开发技术——HTML5、CSS3、JavaScript
一、HTML 1.基本结构 <html lang "en"><head><meta charset"UTF-8"><meta name"Keywords" content""><meta name"Description" content""><title>Web网页标题</title&g…...
野外价值观:在真实世界的语言模型互动中发现并分析价值观
每周跟踪AI热点新闻动向和震撼发展 想要探索生成式人工智能的前沿进展吗?订阅我们的简报,深入解析最新的技术突破、实际应用案例和未来的趋势。与全球数同行一同,从行业内部的深度分析和实用指南中受益。不要错过这个机会,成为AI领…...
【华为HCIP | 华为数通工程师】821—多选解析—第十二页
多选727、某台路由器的输出信息如下所示,以下描述正确的有哪些选项? A、路由器Router ID为10.0.1.1 B、路由器Router ID为10.0.2.2。 C、本路由器的接口地址为10.0.12.2。 D、本路由器是DR。 解析:display ospf peer //获取的OSPF邻居信…...
Selenium 在爬取过程中,网络响应被退出的解决方案
我在使用 Selenium 爬取网站的时候,直接get url ,却立马闪退,遇到了获取网络响应直接被退出的问题。 这通常是由于 反爬机制、浏览器检测 或 网络限制 导致的。 以下是 完整排查与解决方案: 1. 检查常见原因 问题类型典型表现可…...
楼宇自控怎样全方位融入建筑领域,为绿色建筑发展添砖加瓦
在全球积极倡导可持续发展的大背景下,绿色建筑已成为建筑领域发展的必然趋势。绿色建筑旨在减少对环境的负面影响,提高能源利用效率,为用户提供健康、舒适的室内环境。而楼宇自控系统作为建筑智能化的核心组成部分,正以其独特的技…...
语音合成(TTS)从零搭建一个完整的TTS系统-第二节-中文转拼音
一、概述 本节我们进行语音合成前端中的第二步,需要把中文转换为拼音。通过python和c两种语言进行实现,python可以直接调用pypinyin库实现。c实现是本节的重点,首先根据词典进行分词,接着把分词后的词进行词典映射,得到…...
基于springboot的停车位管理系统(源码+数据库)
12基于springboot的停车位管理系统:前端 thymeleaf、Jquery、bootstrap,后端 Springboot、Mybatis,系统角色分为:用户、管理员,管理员在管理后台录入车位信息,用户在线查找车位、预约车位,解决停…...
深入理解 Spring @Configuration 注解
在 Spring 框架中,@Configuration 注解是一个非常重要的工具,它用于定义配置类,这些类可以包含 Bean 定义方法。通过使用 @Configuration 和 @Bean 注解,开发者能够以编程方式创建和管理应用程序上下文中的 Bean。本文将详细介绍 @Configuration 注解的作用、如何使用它以及…...
15.三数之和(LeetCode)java
个人理解: 1.使用双指针做法,首先对数组进行排序 第一重for循环控制第一个数,对数组进行遍历。双指针初始化为lefti1, rigthnums.length-1。然后使用while循环移动双指针寻找合适的数。因为返回的是数,不是下标,数不能…...
2022年全国职业院校技能大赛 高职组 “大数据技术与应用” 赛项赛卷(10卷)任务书
2022年全国职业院校技能大赛 高职组 “大数据技术与应用” 赛项赛卷(10卷)任务书 模块A:大数据平台搭建(容器环境)(15分)任务一:Hadoop 伪分布式安装配置任务二:Flume安装…...
Redis—内存淘汰策略
记:全体LRU,ttl LRU,全体LFU,ttl LFU,全体随机,ttl随机,最快过期,不淘汰(八种) Redis 实现的是一种近似 LRU 算法,目的是为了更好的节约内存&…...
新能源汽车可视化大屏系统毕业设计
以下是一个基于Python和Flask框架的新能源汽车可视化大屏系统后台代码示例。这个系统提供API接口用于前端大屏展示新能源汽车相关数据。 主应用文件 (app.py) python from flask import Flask, jsonify, request from flask_cors import CORS import random from datetime imp…...
02-keil5的配置和使用
一、创建工程 1、在菜单栏”Project”,在弹出的下拉菜单,选择“New uVision Project”。 2、在弹出的对话框,填写工程的名字,例如工程名字为project。 3、为保存的工程,选择对应的芯片。 4、为当前工程,添…...
电脑硬盘丢失怎么找回?解决硬盘数据恢复的2种方法
无论是个人用户还是企业用户来讲,存储在磁盘中的文档、图片、视频、音频等数据都具有相当的价值。但在日常使用过程中,误删操作、病毒攻击、硬件故障等情况都可能造成电脑硬盘突然消失不见数据丢失。面对电脑硬盘丢失这类问题时,采取正确的应…...
【Spring】依赖注入的方式:构造方法、setter注入、字段注入
在Spring框架中,除了构造器注入(Constructor Injection)和Setter注入(Setter Injection),还有一种依赖注入方式:字段注入(Field Injection)。字段注入通过在Bean的字段上…...
涨薪技术|0到1学会性能测试第22课-关联函数web_reg_save_param_ex
前面的推文我们掌握了性能测试脚本开发3种常见的关联技术,今天开始给大家分享关联函数web_reg_save_param_ex,后续文章都会系统分享干货! LoadRunner最新版本中,使用的关联函数为web_reg_save_param_ex,以前的版本使用的关联函数为web_reg_save_param,但这两个函数实质差…...
Vue 的数据代理机制
2025/4/22 向 一、什么是数据代理机制 通过访问代理对象的属性,来间接访问目标对象的属性,数据代理机制的实现需要依赖Object.defineProperty()方法。 如下所示: <!DOCTYPE html> <html lang"en"> <head><…...
Android-KeyStore安全的存储系统
在 Android 中,AndroidKeyStore 是一个安全的存储系统,用于存储加密密钥。它提供了一种安全的方式来生成、存储和管理密钥,而无需将密钥暴露给应用程序本身。以下是如何使用 AndroidKeyStore 的基本步骤和示例代码。 检查 AndroidKeyStor…...
部署私有gitlab网站
以下是建立私有 GitLab 代码版本维护平台的完整步骤,涵盖环境准备、安装配置、初始化及日常管理,适用于企业/团队内部代码托管: 一、环境准备 1. 服务器要求(最低配置) 用途CPU内存存储系统要求小型团队(…...
(区间 dp)洛谷 P6879 JOI2020 Collecting Stamps 3 题解
题意 给定一个周长为 L L L 的圆,从一个点出发,有 N N N 个黑白熊雕像,编号为 1 1 1 到 N N N,第 i i i 个雕像在顺时针 X i X_i Xi 米处,如果你没有在 T i T_i Ti 秒内收集到这个黑白熊雕像,那…...
AtCoder 第402场初级竞赛 A~E题解
A CBC 【题目链接】 原题链接:A - CBC 【考点】 枚举 【题目大意】 找出所有的大写字母 【解析】 遍历字符串,判断是否为大写字母,如果是则输出。 【难度】 GESP二级 【代码参考】 #include <bits/stdc++.h> using namespace std;int main() {string s;ci…...
驱动开发硬核特训 · Day 17:深入掌握中断机制与驱动开发中的应用实战
🎥 视频教程请关注 B 站:“嵌入式 Jerry” 一、前言 在嵌入式驱动开发中,“中断”几乎无处不在。无论是 GPIO 按键、串口通信、网络设备,还是 SoC 上的各种控制器,中断都扮演着核心触发机制的角色。对中断机制掌握程度…...
深入理解依赖、Jar 包与 War 包:Java 开发基石探秘
一、引言 在 Java 开发的广袤天地里,依赖管理如同建筑的基石,默默支撑着项目的稳定构建与运行。而 Jar 包和 War 包,作为 Java 应用的常见打包形式,各自承载着不同的使命。本文将深入探讨依赖的重要性,并清晰解说 Jar…...
01.Python代码Pandas是什么?pandas的简介
01.Python代码Pandas是什么?pandas的简介 提示:帮帮志会陆续更新非常多的IT技术知识,希望分享的内容对您有用。本章分享的是pandas的使用语法。前后每一小节的内容是存在的有:学习and理解的关联性,希望对您有用~ pyth…...
国产紫光同创FPGA实现SDI视频编解码+图像缩放,基于HSSTHP高速接口,提供2套工程源码和技术支持
目录 1、前言工程概述免责声明 2、相关方案推荐我已有的所有工程源码总目录----方便你快速找到自己喜欢的项目本博已有的 SDI 编解码方案本方案在Xilinx--Artix7系列FPGA上的应用本方案在Xilinx--Kintex系列FPGA上的应用本方案在Xilinx--Zynq系列FPGA上的应用本方案在Xilinx--U…...