2010-08-20 57 views
5

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

发布未在FluorineFx中实施或我错过了什么?

回答

0

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

+0

现在,是否有可能在fluorfx中发布? 'ns.publish(publishName.text, “记录”);' – ketan 2015-04-03 06:33:41

2

退房http://www.fluorinefx.com/docs/fluorine/

出版流和下实时订阅流信息功能

+0

谢谢,但我已经阅读过那篇文章。问题是:在FluorineFx的NetStream类中没有attachAudio或发布方法。我认为他们在那篇文章中谈到了Flex的一面。 – 2010-08-21 09:19:47

0

最近,我还查看了fluorfx的代码。奇怪为什么发布不在代码中实现,尽管文档中提到了它。

实际上,在其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)); 
       } 
      } 
     } 
相关问题