火山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);
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/77798.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/77798.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/77798.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

力扣面試150題--插入區間和用最少數量的箭引爆氣球

Day 28 題目描述 思路 初次思路&#xff1a;借鑒一下昨天題解的思路&#xff0c;將插入的區間與區間數組作比較&#xff0c;插入到升序的數組中&#xff0c;其他的和&#xff08;合并區間&#xff09;做法一樣。 注意需要特殊處理一下情況&#xff0c;插入區間比數組中最后一…

【Java面試筆記:基礎】4.強引用、軟引用、弱引用、幻象引用有什么區別?

1. 引用類型及其特點 強引用(Strong Reference): 定義:最常見的引用類型,通過new關鍵字直接創建。回收條件:只要強引用存在,對象不會被GC回收。示例:Object obj = new Object(); // 強引用特點: 強引用是導致內存泄漏的常見原因(如未及時置為null)。手動斷開引用:…

ycsb性能測試的優缺點

YCSB&#xff08;Yahoo Cloud Serving Benchmark&#xff09;是一個開源的性能測試框架&#xff0c;用于評估分布式系統的讀寫性能。它具有以下優點和缺點&#xff1a; 優點&#xff1a; 簡單易用&#xff1a;YCSB提供了簡單的API和配置文件&#xff0c;使得性能測試非常容易…

基于SpringBoot的校園賽事直播管理系統-項目分享

基于SpringBoot的校園賽事直播管理系統-項目分享 項目介紹項目摘要管理員功能圖用戶功能圖項目預覽首頁總覽個人中心禮物管理主播管理 最后 項目介紹 使用者&#xff1a;管理員、用戶 開發技術&#xff1a;MySQLJavaSpringBootVue 項目摘要 隨著互聯網和移動技術的持續進步&…

Nginx?中間件的解析

目錄 一、Nginx的核心架構解析 二、Nginx的典型應用場景 三、Nginx的配置優化實踐 四、Nginx的常見缺陷與漏洞 一、Nginx的核心架構解析 ??事件驅動與非阻塞IO模型?? Nginx采用基于epoll/kq等系統調用的事件驅動機制&#xff0c;通過異步非阻塞方式處理請求&#xff0c;…

杭州小紅書代運營公司-品融電商:全域增長策略的實踐者

杭州小紅書代運營公司-品融電商&#xff1a;全域增長策略的實踐者 在品牌競爭日趨激烈的電商領域&#xff0c;杭州品融電商作為一家專注于品牌化全域運營的服務商&#xff0c;憑借其“效品合一”方法論與行業領先的小紅書代運營能力&#xff0c;已成為眾多品牌實現市場突圍的重…

【映客直播-注冊/登錄安全分析報告】

前言 由于網站注冊入口容易被黑客攻擊&#xff0c;存在如下安全問題&#xff1a; 暴力破解密碼&#xff0c;造成用戶信息泄露短信盜刷的安全問題&#xff0c;影響業務及導致用戶投訴帶來經濟損失&#xff0c;尤其是后付費客戶&#xff0c;風險巨大&#xff0c;造成虧損無底洞…

Android audio_policy_configuration.xml加載流程

目錄 一、audio_policy_configuration.xml文件被加載流程 1、AudioPolicyService 創建階段 2、createAudioPolicyManager 實現 3、AudioPolicyManager 構造 4、配置文件解析 loadConfig 5、核心解析邏輯 PolicySerializer::deserialize 二、AudioPolicyConfig類解析 1、…

使用 Docker 安裝 Elastic Stack 并重置本地密碼

Elastic Stack&#xff08;也被稱為 ELK Stack&#xff09;是一個非常強大的工具套件&#xff0c;用于實時搜索、分析和可視化大量數據。Elastic Stack 包括 Elasticsearch、Logstash、Kibana 等組件。本文將展示如何使用 Docker 安裝 Elasticsearch 并重置本地用戶密碼。 ###…

Unitest和pytest使用方法

unittest 是 Python 自帶的單元測試框架&#xff0c;用于編寫和運行可重復的測試用例。它的核心思想是通過斷言&#xff08;assertions&#xff09;驗證代碼的行為是否符合預期。以下是 unittest 的基本使用方法&#xff1a; 1. 基本結構 1.1 創建測試類 繼承 unittest.TestC…

git 版本提交規范

Git 提交規范&#xff08;Git Commit Message Convention&#xff09;是為了讓項目的提交歷史更加清晰、可讀、便于追蹤和自動化工具解析。常見的規范之一是 Conventional Commits&#xff0c;下面是一個推薦的格式規范&#xff1a; &#x1f31f; 提交信息格式&#xff08;Con…

stat判斷路徑

int stat(const char *pathname, struct stat *buf); pathname&#xff1a;用于指定一個需要查看屬性的文件路徑。 buf&#xff1a;struct stat 類型指針&#xff0c;用于指向一個 struct stat 結構體變量。調用 stat 函數的時候需要傳入一個 struct stat 變量的指針&#xff0…

學習Docker遇到的問題

目錄 1、拉取hello-world鏡像報錯 1. 檢查網絡連接 排查: 2. 配置 Docker 鏡像加速器(推薦) 具體解決步驟: 1.在服務器上創建并修改配置文件,添加Docker鏡像加速器地址: 2. 重啟Docker 3. 拉取hello-world鏡像 2、刪除鏡像出現異常 3、 容器內部不能運行ping命令 …

安寶特案例 | AR如何大幅提升IC封裝廠檢測效率?

前言&#xff1a;如何提升IC封裝廠檢測效率&#xff1f; 在現代電子產品的制造過程中&#xff0c;IC封裝作為核心環節&#xff0c;涉及到復雜處理流程和嚴格質量檢測。這是一家專注于IC封裝的廠商&#xff0c;負責將來自IC制造商的晶圓進行保護、散熱和導通處理。整個制程繁瑣…

【Linux網絡與網絡編程】07.應用層協議HTTPS

HTTP 協議內容都是按照文本的方式明文傳輸的&#xff0c;這就導致在傳輸過程中出現一些被篡改的情況。HTTPS 就是在 HTTP 協議的基礎上引入了一個加密層的應用層協議。 1. 基礎概念 1.1 加密與解密 加密就是把明文&#xff08;要傳輸的信息&#xff09;進行一系列變換&#x…

【k8s】PV,PVC的回收策略——return、recycle、delete

PV 和 PVC 的回收策略主要用于管理存儲資源的生命周期&#xff0c;特別是當 PVC 被刪除時&#xff0c;PV 的處理方式。回收策略決定了 PV 在 PVC 被刪除后的行為。 回收策略的類型 Kubernetes 提供了三種主要的回收策略&#xff0c;用于管理 PV 的生命周期&#xff1a; Reta…

2023藍帽杯初賽內存取證-2

直接使用mimikatz插件來獲取用戶密碼&#xff1a; vol.py --plugin/opt/volatility/plugins -f memdump.mem --profile Win7SP1x64 mimikatz 答案&#xff1a;3w.qax.com

使用dompurify修復XSS跨站腳本缺陷

1. 問題描述 漏洞掃描說有一個低危漏洞&#xff0c;容易被跨站腳本攻擊XSS。 2. 使用dompurify修復 DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. 簡單來說&#xff0c;我們可以使用 dompurify 處理xss跨站腳本攻擊。 2.…

【c語言】指針和數組筆試題解析

一維數組: //數組名a如果既不單獨放在sizeof()中&#xff0c;也不與&結合&#xff0c;那么就表示數組首元素的大小 //a一般表示數組首元素地址&#xff0c;只有兩種情況表示整個數組&#xff0c;sizeof(arr)表示整個數組的大小&#xff0c;&arr表示數組的地址 int a[]…

機器人進階---視覺算法(六)傅里葉變換在圖像處理中怎么用

傅里葉變換在圖像處理中怎么用 傅里葉變換的基本原理應用場景Python代碼示例逐行解釋總結傅里葉變換在圖像處理中是一種重要的工具,它將圖像從空間域轉換到頻域,從而可以對圖像的頻率特性進行分析和處理。傅里葉變換在圖像濾波、圖像增強、圖像壓縮和圖像分析等方面都有廣泛應…