Results 1 to 7 of 7

Thread: republish stream from one application to other

  1. #1

    Default republish stream from one application to other

    I need to publish stream, which plays in application "app1", on application "app2"
    I try into module for "app2":
    			IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
    			IApplicationInstance app1Instance = vhost.getApplication("app1").getAppInstance("_definst_");
    			IMediaStream mediaStream = app1Instance.getStreams().getStream("streamNameInLive");
    			if (mediaStream != null) {
    			    publisher = Publisher.createInstance(app2Instance);
    			    publisher.setStream(mediaStream);
    			    publisher.setFileExtension("flv");
    			    publisher.setStreamType("live");
    			    publisher.publish("newStreamName", "live");
    			}
    and publisher creates stream "newStreamName" in app1, where there is "streamNameInLive"..but i need "newStreamName" stream in app2.

    How can i solve my problem?

    or.. if i create Stream object :
    Stream stream = Stream.createInstance(appInstance, "newStreamName");
    stream.play("streamNameInLive", -2, -1, true);
    this works if "streamNameInLive" in same application, but how do this, if stream in another application?
    Last edited by dmitriy.kirakosyan; 03-21-2012 at 05:44 AM. Reason: code wrap

  2. #2
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    In your first example, using the Push Publishing API, you can do it if the application you publish to is app1, and it uses Push Publish API to push to app2. Then you will be able to play the live stream from both. Or, you can create a 2nd PushPublisherRTMP object (publisher2) in the application you publish to and use one to push to app1 and the other to push to app2.

    Another approach is use LiveRepeater. Publish to one application, and re-stream in another. Same result: you can play same stream from two apps.

    Richard

  3. #3

    Default

    Richard, if i understand correctly, i need to use Push Publish Addon, right? I can't do what i want with Publish class, isn't it?

  4. #4

    Default

    I just tried this:
    public class StreamPacketTest implements Runnable {
    	private final IMediaStream mediaStream;
    
    	public StreamPacketTest(IMediaStream mediaStream) {
    		this.mediaStream = mediaStream;
    	}
    
    	public void run() {
    		AMFPacket packet = null;
    		IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
    		IApplicationInstance appInstance = vhost.getApplication("live").getAppInstance("_definst_");
    		Publisher publisher = Publisher.createInstance(appInstance);
    		publisher.setFileExtension("flv");
    		publisher.setStreamType("live");
    		publisher.publish("11", "live");
    		while (true) {
    			if (packet != mediaStream.getLastPacket()) {
    				packet = mediaStream.getLastPacket();
    				switch (packet.getType()) {
    					case IVHost.CONTENTTYPE_AUDIO:
    						publisher.addAudioData(packet.getData(), packet.getSize(), packet.getTimecode());
    						break;
    					case IVHost.CONTENTTYPE_VIDEO:
    						publisher.addVideoData(packet.getData(), packet.getSize(), packet.getTimecode());
    						break;
    					case IVHost.CONTENTTYPE_DATA:
    						publisher.addDataData(packet.getData(), packet.getSize(), packet.getTimecode());
    						break;
    				}
    			}
    
    		}
    	}
    }
    But it doesn't work.. I have console traces :

    WARN server comment - CupertinoPacketHandler.handlePacket[live/_definst_/11]: Timecode out of order [audio]: 46:1423
    and when i'm trying to watch stream 11 from application "live", i see one frozen frame

  5. #5

    Default

    If i instead
    packet.getTimecode()
    use
    packet.getAbsTimecode()
    , then no WARN in console and i can watch new stream, but with time lags..

  6. #6
    Join Date
    Dec 2007
    Posts
    21,962

    Default

    Try the Push Publish addon or Liverepeater, as suggested.

    Richard

  7. #7

    Default

    Thanks, Richard. PushPublishRTMP works nice.

Similar Threads

  1. Republish a stream from one application to another on demand
    By federico in forum Server-side Modules and Code Samples Discussion
    Replies: 5
    Last Post: 06-28-2012, 05:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •