【问题标题】:How to publish an audio stream from a client with FluorineFx?如何使用 FluorineFx 从客户端发布音频流?
【发布时间】:2011-04-01 13:29:27
【问题描述】:

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

发布未在 FluorineFx 中实现还是我遗漏了什么?

【问题讨论】:

    标签: c# apache-flex streaming rtmp fluorinefx


    【解决方案1】:

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

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

    【讨论】:

    • 谢谢,但我已经阅读了那篇文章。问题是: FluorineFx 中的 NetStream 类中没有 attachAudio 或 publish 方法。我认为他们在那篇文章中谈到了 Flex 方面。
    【解决方案2】:

    不幸的是,这个功能似乎没有实现。

    【讨论】:

    • 现在,是否可以在 fluorinefx 中发布? ns.publish(publishName.text,"record");
    【解决方案3】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 2011-01-20
      • 2021-12-11
      • 2016-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-16
      相关资源
      最近更新 更多