최근에 불소의 코드도 살펴 봅니다. 의사가 언급 했음에도 불구하고 게시가 코드에 구현되지 않은 이유는 이상합니다.
실제로 PlayEngine.cs에는 FLV 파일에서 데이터를 가져 와서 원격으로 푸시 할 수있는 유사한 구현 PullAndPush()가 있습니다.
그래서, 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));
}
}
}
이제 불소에 게시 할 수 있습니까? 'ns.publish (publishName.text, "record");' – ketan