首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过FluorineFx发布客户端的音频流?

如何通过FluorineFx发布客户端的音频流?
EN

Stack Overflow用户
提问于 2010-08-20 16:56:09
回答 3查看 1.8K关注 0票数 5

我不知道如何在客户端使用FluorineFx将音频流从客户端发布到服务器。我们希望通过已经建立的NetConnection将录制的音频数据从客户端流式传输到流。FluorineFx中有一个NetStream类,但它没有publish方法。FluorineFx中的NetStream类只有play方法。但据我所知,这将在客户机上播放来自服务器的流。

publish没有在FluorineFx中实现,还是我遗漏了什么?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-03-16 23:38:59

不幸的是,这个特性似乎没有被实现。

票数 0
EN

Stack Overflow用户

发布于 2010-08-20 21:50:25

查看http://www.fluorinefx.com/docs/fluorine/

请参阅实时消息传递下的发布流和订阅流

票数 2
EN

Stack Overflow用户

发布于 2016-06-11 20:24:52

最近,我也研究了fluorinefx的代码。奇怪的是,尽管文档中提到了发布,但代码中没有实现发布。

实际上,在它的PlayEngine.cs中,有一个类似的实现PullAndPush(),它可以从FLV文件中提取数据并将其推送到远程。

因此,我在Netstream类中尝试了一些类似的代码,它几乎可以工作,可以将流推送到rtmplite服务器,并且可以在rtmplite中的测试网站上播放。

代码语言:javascript
复制
public void Publish(params object[] arguments)
        {
            ValidationUtils.ArgumentConditionTrue(arguments != null && arguments.Length > 0, "arguments", "At least the name of a file must be specified");
            ValidationUtils.ArgumentNotNullOrEmptyOrWhitespace(arguments[0] as string, "name");
            _name = arguments[0] as string;


            INetConnectionClient client = _connection.NetConnectionClient;
            RtmpConnection connection = _connection.NetConnectionClient.Connection as RtmpConnection;
            IPendingServiceCallback callback = new CreateStreamCallBack(this, connection, new PublishCallBack(this,_connection, _name));
            client.Call("createStream", callback);
        }

        public void AttachFile(string filepath)
        {

            FileProvider fileProvider = new FileProvider(this.Scope, new System.IO.FileInfo(filepath));
            _pullPushPipe.Subscribe(fileProvider, null);
            PullAndPush();
        }

        public void PullAndPush()
        {

            while(true)
            {
                var msg = _pullPushPipe.PullMessage();
                if (msg == null)
                {
                    // No more packets to send
                    Stop();
                    break;
                }
                else
                {
                    if (msg is RtmpMessage)
                    {
                        RtmpMessage rtmpMessage = (RtmpMessage)msg;
                        IRtmpEvent body = rtmpMessage.body;
                     //   SendMessage(rtmpMessage);
                        // Adjust timestamp when playing lists
                        //  EnsurePullAndPushRunning();
                        _pullPushPipe.PushMessage(msg);
                    }
                }
            }
        }

        class PublishCallBack : IPendingServiceCallback
        {
            NetConnection _connection;
            NetStream _stream;
            string _name;
            string _mode;

            public PublishCallBack(NetStream stream, NetConnection connection, string name, string mode = "live")
            {
                _connection = connection;
                _name = name;
                _mode = mode;
                _stream = stream;
            }

            public void ResultReceived(IPendingServiceCall call)
            {
                if ("createStream".Equals(call.ServiceMethodName))
                {
                    RtmpConnection connection = _connection.NetConnectionClient.Connection as RtmpConnection;
                    object[] args = new object[2] {_name, _mode};
                    PendingCall pendingCall = new PendingCall("publish", args);
                    pendingCall.RegisterCallback(new PublishResultCallBack());
                    connection.Invoke(pendingCall, (byte)connection.GetChannelForStreamId(_stream.StreamId));
                }
            }
        }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3529443

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档