简体   繁体   English

Agora 多对一直播

[英]Agora many to one live streaming

I have a requirement in which different user will stream videos from their camera to a server and there will be dashboard in which the admin can view all the streams real-time something like how surveillance works?我有一个要求,不同的用户将视频从他们的相机流式传输到服务器,并且会有一个仪表板,管理员可以在其中实时查看所有流,比如监控是如何工作的? I think video broadcasting can help but the documentation says it enables live streaming from one-to-many and many-to-many but there is no mention of the many-to-one case.我认为视频广播可以提供帮助,但文档说它可以实现一对多和多对多的直播,但没有提到多对一的情况。 How can I achieve this?我怎样才能做到这一点?

The use-case you have described would be implemented the same way as a many-to-many broadcast.您描述的用例将以与多对多广播相同的方式实现。

For your use-case you would have all of the camera streams join the channel as broadcasters and then the "surveillance" user would join as an audience .对于您的用例,您将让所有摄像机流作为广播者加入频道,然后“监视”用户将作为观众加入。 The audience member subscribes to all the remote streams without having to broadcast a stream of their own.观众成员订阅所有远程流,而不必广播自己的流。

[Update] [更新]
With Agora's SDK you can use an external video source, you would just have to manage it yourself.使用 Agora 的 SDK,您可以使用外部视频源,您只需要自己管理它。 If you are using a custom video source then you don't need to use RTMP.如果您使用的是自定义视频源,则不需要使用 RTMP。

IVideoFrameConsumer mConsumer;
boolean mHasStarted;

// Create a VideoSource instance.
VideoSource source = new VideoSource() {
    @Override
    public int getBufferType() {
        // Get the current frame type. 
        // The SDK uses different methods to process different frame types.
        // If you want to switch to another VideoSource type, create another instance.
        // There are three video frame types: BYTE_BUFFER(1); BYTE_ARRAY(2); TEXTURE(3)
        return BufferType.BYTE_ARRAY;
    }

    @Override
     public boolean onInitialize(IVideoFrameConsumer consumer) {
        // Consumer was created by the SDK.
        // Save it in the lifecycle of the VideoSource.
        mConsumer = consumer;
    }

    @Override
     public boolean onStart() {
        mHasStarted = true;
    }

    @Override
      public void onStop() {
        mHasStarted = false;
    }

    @Override
     public void onDispose() {
        // Release the consumer.
        mConsumer = null;
    }
};

// Change the inputting video stream to the VideoSource instance.
rtcEngine.setVideoSource(source);

// After receiving the video frame data, use the consumer class to send the data.
// Choose differnet methods according to the frame type.
// For example, the current frame type is byte array, i.e. NV21.
if (mHasStarted && mConsumer != null) {
    mConsumer.consumeByteArrayFrame(data, AgoraVideoFrame.NV21, width, height, rotation, timestamp);
}

full guide: https://docs.agora.io/en/Video/custom_video_android?platform=Android完整指南: https : //docs.agora.io/en/Video/custom_video_android?platform=Android

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM