[Red5] Cannot subscribe to Live Stream if its being Recorded
Steven Gong
steven.gong at gmail.com
Tue Dec 12 00:28:17 EST 2006
On 12/12/06, Dan Rossi <spam at electroteque.org> wrote:
>
> Hi this is the patch that i sent to be fixed, and it was said to be fixed
> months ago ! so just copy the code from live into record ? why did it get
> reverted ?
>
Well, I think it's just a workaround rather than a fix because I don't think
we should publish every stream when it's recorded. Does FMS do this?
Costin Tuculescu wrote:
>
> Hi Dan,
>
> I've made a modification to the publish method in the StreamService.javaclass, and it did the trick for me. Notice the parts commented with "Added
> by CT..."
>
> public void publish(String name, String mode) {
> log.info("publish: " + name + ", " + mode);
>
> IConnection conn = Red5.getConnectionLocal();
> if (!(conn instanceof IStreamCapableConnection)) return;
> IStreamCapableConnection streamConn = (IStreamCapableConnection)
> conn;
> int streamId = getCurrentStreamId();
> IClientStream stream = streamConn.getStreamById(streamId);
> if (stream != null && !(stream instanceof IClientBroadcastStream))
> return;
> if (stream == null)
> stream = streamConn.newBroadcastStream(streamId);
>
> IClientBroadcastStream bs = (IClientBroadcastStream) stream;
> try {
> if (IClientStream.MODE_RECORD.equals(mode)) {
> //Added by CT to play and record at the same time:
> IContext context = conn.getScope().getContext();
> IProviderService providerService = (IProviderService)
> context.getBean(IProviderService.KEY);
> bs.setPublishedName(name);
> // TODO handle registration failure
> if (providerService.registerBroadcastStream(conn.getScope(),
> name, bs)) {
> IBroadcastScope bsScope = getBroadcastScope(
> conn.getScope(), bs.getPublishedName());
> bsScope.setAttribute(IBroadcastScope.STREAM_ATTRIBUTE,
> bs);
> if (conn instanceof BaseConnection)
> ((BaseConnection)
> conn).registerBasicScope(bsScope);
> }
> // end add
>
> bs.start();
> bs.saveAs(name, false);
> } else if (IClientStream.MODE_APPEND.equals(mode)) {
> // Added by CT to play and record at the same time:
> IContext context = conn.getScope().getContext();
> IProviderService providerService = (IProviderService)
> context.getBean(IProviderService.KEY);
> bs.setPublishedName(name);
> // TODO handle registration failure
> if (providerService.registerBroadcastStream(conn.getScope(),
> name, bs)) {
> IBroadcastScope bsScope = getBroadcastScope(
> conn.getScope(), bs.getPublishedName());
> bsScope.setAttribute(IBroadcastScope.STREAM_ATTRIBUTE,
> bs);
> if (conn instanceof BaseConnection)
> ((BaseConnection)
> conn).registerBasicScope(bsScope);
> }
> // end add
>
> bs.start();
> bs.saveAs(name, true);
> } else if (IClientStream.MODE_LIVE.equals(mode)) {
> IContext context = conn.getScope().getContext();
> IProviderService providerService = (IProviderService)
> context.getBean(IProviderService.KEY);
> bs.setPublishedName(name);
> // TODO handle registration failure
> if (providerService.registerBroadcastStream(conn.getScope(),
> name, bs)) {
> IBroadcastScope bsScope = getBroadcastScope(
> conn.getScope(), bs.getPublishedName());
> bsScope.setAttribute(IBroadcastScope.STREAM_ATTRIBUTE,
> bs);
> if (conn instanceof BaseConnection)
> ((BaseConnection)
> conn).registerBasicScope(bsScope);
> }
> bs.start();
> }
> } catch (Exception e) {
> // TODO report publish error
> }
> }
>
> So try replacing the original publish function in that class with this
> one, and let me know if it does the trick. It worked for me. I've been
> meaning to submit it back to the community but I've just been slammed, plus
> I don't really know how to go about putting this type of stuff in the trunk,
> nor am I any good at programming Java. The mod I made just made sense based
> on the stream being published as live -- the recorded streams didn't seem to
> be registering themselves with the scope. So yeah, let me know. Thanks.
>
> -Costin
>
>
> ----Original Message Follows----
> From: Dan Rossi <spam at electroteque.org> <spam at electroteque.org>
> Reply-To: Red5 at osflash.org
> To: Red5 at osflash.org
> Subject: Re: [Red5] Cannot subscribe to Live Stream if its being Recorded
> Date: Tue, 12 Dec 2006 15:30:42 +1100
>
> any solutions ?
>
> Dan Rossi wrote:
>
> Hi does someone have a solution for subscribing to an archiving stream,
> this hack below doesnt work, the broadcast stops at the server immediately.
> If i try play(stream, -1) the subscribe just hangs like the stream isnt
> available even though the server aknowledges the publish name and the server
> stream aware handlers work fine and call the clients when a broadcast is
> happening just cant stream.
>
> I am using the filenamegenerator bean to record to one path, and playback
> a trailer in another path, could this be the problem, ive had my ticket open
> for ages now and got an ignorant response.
>
> If i call with play(stream, -2) i get an exception
>
> [java] [ERROR] 1020437 pool-1-thread-15:(
> org.red5.io.flv.impl.FLVReader.er
> ror ) Error fillBuffer
> [java] java.lang.IllegalArgumentException
> [java] at java.nio.ByteBuffer.allocate(ByteBuffer.java:311)
> [java] at org.red5.io.flv.impl.FLVReader.fillBuffer(
> FLVReader.java:242)
>
> [java] at org.red5.io.flv.impl.FLVReader.setCurrentPosition(
> FLVReader.j
> ava:170)
> [java] at org.red5.io.flv.impl.FLVReader.analyzeKeyFrames(
> FLVReader.jav
> a:527)
> [java] at org.red5.io.flv.impl.FLVReader.postInitialize(
> FLVReader.java:
> 264)
> [java] at org.red5.io.flv.impl.FLVReader.<init>(FLVReader.java:275)
>
> [java] at org.red5.io.flv.impl.FLV.getReader(FLV.java:172)
> [java] at org.red5.server.stream.provider.FileProvider.init(FileProvide
>
> r.java:179)
> [java] at
> org.red5.server.stream.provider.FileProvider.pullMessage(File
> Provider.java:87)
> [java] at
> org.red5.server.messaging.InMemoryPullPullPipe.pullMessage(In
> MemoryPullPullPipe.java:72)
> [java] at
> org.red5.server.stream.PlaylistSubscriberStream$PlayEngine.pu
> llAndPush(PlaylistSubscriberStream.java:847)
> [java] at
> org.red5.server.stream.PlaylistSubscriberStream$PlayEngine.pl
> ay(PlaylistSubscriberStream.java:681)
> [java] at org.red5.server.stream.PlaylistSubscriberStream.play(Playlist
>
> SubscriberStream.java:124)
> [java] at org.red5.server.stream.StreamService.play(
> StreamService.java:
> 179)
> [java] at org.red5.server.stream.StreamService.play(
> StreamService.java:
> 187)
> [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
>
> sorImpl.java:39)
> [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
>
> hodAccessorImpl.java:25)
> [java] at java.lang.reflect.Method.invoke(Method.java:585)
> [java] at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.
>
> java:161)
> [java] at org.red5.server.net.rtmp.RTMPHandler.invokeCall(
> RTMPHandler.j
> ava:135)
> [java] at org.red5.server.net.rtmp.RTMPHandler.onInvoke(
> RTMPHandler.jav
> a:276)
> [java] at
> org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived(Base
> RTMPHandler.java:114)
> [java] at
> org.red5.server.net.rtmp.RTMPMinaIoHandler.messageReceived(RT
> MPMinaIoHandler.java:84)
> [java] at
> org.apache.mina.common.support.AbstractIoFilterChain$2.messag
> eReceived(AbstractIoFilterChain.java:189)
> [java] at
> org.apache.mina.common.support.AbstractIoFilterChain.callNext
> MessageReceived(AbstractIoFilterChain.java:502)
> [java] at
> org.apache.mina.common.support.AbstractIoFilterChain.access$1
> 000(AbstractIoFilterChain.java:52)
> [java] at
> org.apache.mina.common.support.AbstractIoFilterChain$EntryImp
> l$1.messageReceived(AbstractIoFilterChain.java:777)
> [java] at org.red5.io.filter.ExecutorFilter.processEvent(ExecutorFilter
>
> .java:231)
> [java] at
> org.red5.io.filter.ExecutorFilter$ProcessEventsRunnable.run(E
> xecutorFilter.java:280)
> [java] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Thread
>
> PoolExecutor.java:650)
> [java] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPool
>
> Executor.java:675)
> [java] at java.lang.Thread.run(Thread.java:595)
> [java] [INFO] 1020453 pool-1-thread-15:(
> org.red5.io.flv.impl.FLVReader.inf
> o ) New position exceeds limit
> [java] [INFO] 1020453 pool-1-thread-15:(
> org.red5.server.stream.PlaylistSub
> scriberStream.info ) Scheduled stop in: 1879753393
>
> I just checked with FMS, and my ported application was fine, subscribes at
> it records.
>
> Alex Zimin wrote:
>
> I have the following code and it works just fine for me.
> ns.publish("stream1", "live");
> ns.publish("stream2", "record");
> Client, which connects to live stream, is able to play it, and recording
> happens at the same time.
> However I have a different problem. When I stop recording, by issuing
> ns.close("stream2"); command, it closes both streams.
> I am using Red5 0.6RC1.
> Any help?
> Thanks,
> Alex.
>
>
>
> _______________________________________________
> Red5 mailing list
> Red5 at osflash.org
> http://osflash.org/mailman/listinfo/red5_osflash.org
>
>
>
>
>
> _______________________________________________
> Red5 mailing list
> Red5 at osflash.org
> http://osflash.org/mailman/listinfo/red5_osflash.org
>
> _________________________________________________________________
> All-in-one security and maintenance for your PC. Get a free 90-day trial!
>
> http://clk.atdmt.com/MSN/go/msnnkwlo0050000002msn/direct/01/?href=http://clk.atdmt.com/MSN/go/msnnkwlo0050000001msn/direct/01/?href=http://www.windowsonecare.com/?sc_cid=msn_hotmail
>
>
> ------------------------------
>
> _______________________________________________
> Red5 mailing list
> Red5 at osflash.org
> http://osflash.org/mailman/listinfo/red5_osflash.org
>
>
>
> _______________________________________________
> Red5 mailing list
> Red5 at osflash.org
> http://osflash.org/mailman/listinfo/red5_osflash.org
>
>
>
--
I cannot tell why this heart languishes in silence. It is for small needs it
never asks, or knows or remembers. -- Tagore
Best Regards
Steven Gong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/red5_osflash.org/attachments/20061212/f502a76f/attachment-0001.htm
More information about the Red5
mailing list