MLVB SDK

repository·master·Indexed 20 days ago

https://github.com/tencentyun/mlvbsdk

A mobile live streaming component kit based on Tencent Cloud's LiteAV audio/video framework. It provides tools for pushing/pulling streams and co-hosting (PK) functionality. Available in Smart, Professional, and Enterprise editions for Android and iOS, featuring support for camera/screen recording push, live playback, RTC, and third-party beauty SDK integration.

Tokens
19.9K
Snippets
52
Records
101
Agent score
23%

What's inside mlvbsdk

  1. Overview of MLVB API-Example Scenarios

    master

    The MLVB-API-Example project provides implementation examples for various live streaming scenarios. The project is organized into Basic and Advanced features:

    Basic Features

    • Camera Push: Streaming via device camera (LivePushCamera).
    • Screen Recording Push: Streaming the device screen (LivePushScreen).
    • Live Playback: Playing a live stream (LivePlay).
    • Interactive Link: Real-time interaction/connection (LiveLink).
    • Link PK: PK battles/interactivity (LinkPK).

    Advanced Features

    • Dynamic Render Switching: Switching rendering components on the fly (SwitchRenderView).
    • Custom Video Capture: Using custom video sources (CustomVideoCapture).
    • Third-party Beauty: Integrating external beauty/makeup filters (ThirdBeauty).
    • RTC Push & Play: Combining RTC connection with ultra-low latency playback (RTCPushAndPlay).
  2. Overview of XiaoZhiBo App

    master

    XiaoZhiBo App is an open-source, complete online live streaming solution. It is built upon Cloud Live services and Instant Messaging (IM), utilizing Serverless (Cloud Functions) to provide standard backend services.

    Key features include:

    • User Login and Registration
    • Live Streaming (Start Broadcast)
    • Room Lists
    • Mic-link Interaction (Multi-guest interaction)
    • Text Interaction and Danmaku (Bullet chat) messages
  3. Explore MLVB API usage scenarios

    master

    The MLVB API-Example project provides implementations for various live streaming scenarios. You can explore these by navigating to the corresponding directories in the source code:

    Basic Functionality

    • Camera Push: Basic/LivePushCamera - Streaming via the device camera.
    • Screen Recording Push: Basic/LivePushScreen - Streaming the device screen.
    • Live Playback: Basic/LivePlay - Standard live stream playback.
    • Leb Playback: Basic/LebPlay - Fast/Low-latency playback.
    • Interactive Linkage: Basic/LiveLink - Real-time interaction/connection.
    • Link PK: Basic/LinkPK - PK (Player Killing/Battle) interaction mode.

    Advanced Functionality

    • Custom Video Capture: Advanced/CustomVideoCapture - Using custom video sources.
    • Third-party Beauty: Advanced/ThirdBeauty - Integrating external beauty filters.
    • RTC Linkage + Ultra-low Latency Playback: Advanced/RTCPushAndPlay - Combining RTC and low-latency playback.
    • Picture in Picture: Advanced/PictureInPicture - PiP mode support.
    • Leb Adaptive Bitrate: Advanced/LebAutoBitrate - Adaptive playback for Leb streams.
  4. Understand the Android Demo project structure

    master

    The Android repository contains Demo source code demonstrating basic API calls and core functionalities. The structure is as follows:

    • Demo/app: The main entry point of the application.
    • Demo/audioeffectsettingkit: Audio effects panel (BGM playback, voice changing, reverb, pitch shifting, etc.).
    • Demo/beautysettingkit: Beauty settings panel (beautification, filters, motion effects, etc.).
    • Demo/debug: Includes GenerateTestUserSig for generating local test UserSigs.
    • Demo/login: A simple demonstration login interface.
    • Demo/liveplayerdemo: Live playback functionality (supports playing via scanned URL addresses).
    • Demo/livepusherdemo: Live streaming (push) functionality, including basic operations like setting beauty and audio effects during streaming.
    • Demo/livelinkmicdemoold: Interactive live streaming (includes features like mic linking/co-hosting, chat, and liking).
  5. Understand the iOS Demo project structure

    master

    The iOS directory contains Demo source code demonstrating basic API calls and core functionalities. The structure is as follows:

    • SDK/: Contains the framework files (TXLiteAVSDK_Smart.framework, TXLiteAVSDK_Professional.framework, or TXLiteAVSDK_Enterprise.framework) depending on your downloaded version.
    • Demo/: Contains the mobile live streaming demos.
    • TXLiteAVDemo/ (Main Demo Modules):
      • App: The main entry point of the application.
      • AudioSettingKit: Audio effects panel (BGM playback, voice changing, reverb, pitch shifting, etc.).
      • BeautySettingKit: Beauty effects panel (beauty filters, filters, motion effects, etc.).
      • Debug: Includes GenerateTestUserSig for generating local test UserSigs.
      • LivePlayerDemo: Live streaming playback (supports playing via scanned URL/QR code).
      • LivePusherDemo: Live streaming push (includes basic operations like setting beauty and audio effects during streaming).
      • Login: A simple demonstration login interface.
      • LiveLinkMicDemoOld: Interactive live streaming (includes features like mic linking/co-hosting, chat, and liking).
  6. MLVB API-Example Feature Overview

    master

    The demo project is organized into Basic and Advanced feature sets to demonstrate SDK capabilities:

    Basic Features

    • Publishing from Camera: LivePushCamera
    • Publishing from Screen: LivePushScreen
    • Playback: LivePlay
    • Leb Playback: LebPlay
    • Co-anchoring: LiveLink
    • Competition: LinkPK

    Advanced Features

    • Custom Video Capturing: CustomVideoCapture
    • Third-Party Beauty Filters: ThirdBeauty
    • RTC Co-anchoring + Ultra-low-latency Playback: RTCPushAndPlay
    • Webrtc Auto Bitrate: LebAutoBitrate
  7. Use TXLivePusher and TXLivePlayer features

    master

    The SDK includes specialized components for streaming and playback:

    • TXLivePusher (Streaming): Supports License verification and provides raw audio data callbacks. It also supports setting mute for live stream motion effects.
    • TXLivePlayer (Playback): Supports real-time streaming modes, HLS multi-bitrate switching, and 'Time-shift' (时移回看) for live broadcasts. In real-time mode, if an acceleration address cannot be obtained, it may throw error code -2302 and stop automatic switching to CDN playback.
  8. Handle mlvb-live-room component events

    master

    The component communicates internal state changes and interactions via the onRoomEvent callback. The event detail follows this structure:

    "detail": {
      "tag": "Unique event tag identifier",
      "code": "Event code",
      "detail": "Detailed parameters corresponding to the event"
    }

    Common Event Tags:

    • roomClosed: The room has been closed.
    • error: An error occurred. Check e.detail.code and e.detail.detail for specifics.
    • recvTextMsg: A text message was received. The message content is in e.detail.detail.
    • requestJoinAnchor: An audience member is requesting to join the anchor (co-hosting). The audience object is in e.detail.
    • linkOn: Notifies a co-hosting audience member that the connection was successful.
    • linkOut: Notifies a co-hosting audience member that they have exited the co-hosting session.
    onRoomEvent: function(e){
        switch(e.detail.tag){
            case 'roomClosed': {
                // Room is closed
                break;
            }
            case 'error': {
                var code = e.detail.code;
                var detail = e.detail.detail;
                break;
            }
            case 'recvTextMsg': {
                var text = e.detail.detail;
                break;
            }
            case 'requestJoinAnchor': {
                var audience = e.detail;
                var name = audience.userName;
                var id = audience.userID;
                // To allow the request (as anchor):
                var liveroom = this.selectComponent("#id_liveroom");
                liveroom.respondJoinAnchor(true, audience);
                break;
            }
            case 'linkOn': {
                // Co-host connected successfully
                break;
            }
            case 'linkOut': {
                // Co-host disconnected
                break;
            }
        }
    }
  9. Quickstart: Run the MLVB API-Example Demo

    master

    The MLVB-API-Example is an open-source Android demo designed to help developers understand and implement MLVB SDK features. It covers basic features like camera/screen publishing and playback, as well as advanced features like custom video capturing and third-party beauty filters.

    Environment Requirements

    • Android OS: 4.1 (API level 16) or above (Android 5.0+ recommended).
    • Android Studio: 3.5 or above.
    • Hardware: Physical devices with Android 5.0 or above are recommended for testing.

    High-Level Setup Workflow

    1. Obtain Credentials: Get your SDKAppID and secret key from the TRTC console.
    2. Activate Services: Activate CSS (Cloud Storage Service) and obtain a trial license.
    3. Configure Demo: Update GenerateTestUserSig.java files with your credentials and domain names.
    4. Integrate SDK: Use Gradle (JCenter) or manual AAR import.
    5. Run: Compile and run via Android Studio on a connected device.
  10. Integrate FaceUnity Third-Party Beauty SDK

    master

    To enable advanced beauty features in the MLVB SDK iOS project, you must integrate the FaceUnity SDK. Follow these steps:

    1. Download the SDK: Download the FaceUnity SDK for iOS (e.g., version 7.4.0) from FaceUnity.
    2. Import Frameworks:
      • Drag the unzipped library folder into your Xcode project and ensure Copy items if needed is checked.
      • Critical: libCNamaSDK.framework is a dynamic library. You must add it under General -> Frameworks, Libraries, and Embedded Content and set the Embed setting to Embed & Sign. Failure to do this will cause the app to crash at runtime because the library cannot be found.
    3. Add FaceUnity Source Files: Download the FUTRTCDemo from GitHub and drag the following files from the FaceUnity directory into your project (ensure Copy items if needed is checked):
      • authpack.h
      • FUBeautyParam.h
      • FUBeautyParam.m
      • FUDateHandle.h
      • FUDateHandle.m
      • FUManager.h
      • FUManager.m
    4. Configure Authentication: In authpack.h, replace the existing certificate key with a test certificate obtained from FaceUnity. Once replaced, you can comment out or delete the error warning in that file.