5

クライアントで FluorineFx を使用してクライアントからサーバーにオーディオ ストリームを公開する方法がわかりません。既に確立されている NetConnection を介して、記録されたオーディオ データをクライアントからストリームにストリーミングしたいと考えています。FluorineFx には NetStream クラスがありますが、publish メソッドはありません。FluorineFx の NetStream クラスには play メソッドしかありません。しかし、私が理解している限り、これはクライアント上のサーバーからのストリームを再生します。

パブリッシュは FluorineFx に実装されていませんか、それとも見逃していますか?

4

3 に答える 3

2

http://www.fluorinefx.com/docs/fluorine/をご覧ください

Real-time Messaging のストリームの公開とストリームへのサブスクライブを参照してください。

于 2010-08-20T13:50:24.933 に答える
0

残念ながら、この機能は実装されていないようです。

于 2011-03-16T15:38:59.037 に答える
0

最近は、fluorefxのコードも調べています。ドキュメントで言及されているにもかかわらず、コードにパブリッシュが実装されていないのは奇妙です。

実際、その PlayEngine.cs には、FLV ファイルからデータをプルしてリモートにプッシュできる同様の実装の PullAndPush() があります。

そこで、Netstream クラスで同様のコードをいくつか試してみました。ほぼ動作し、ストリームをrtmpliteサーバーにプッシュして、 rtmpliteのテスト Web で再生できます。

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));
                }
            }
        }
于 2016-06-11T12:24:52.407 に答える