Results 1 to 6 of 6

Thread: get IMediaStream instance of video on demand stream

  1. #1
    Join Date
    Oct 2013
    Posts
    26

    Default get IMediaStream instance of video on demand stream

    My requirement: when flash based publisher sends cue-point to server, i should inject custom metadata into the stream.
    But client.getAppinstance().getStreams().getStream(vodstreamName) and
    client.getAppinstance().getPlayStreamsByName(vodStreamName) returns null inside cuepoint method on server-side.
    How can i get stream instance of vod to send metadata?

  2. #2
    Join Date
    Oct 2013
    Posts
    26

    Default

    It turns out to be that we shouldn't include "mp4:" in vodstreamName. Now client.getAppInstance().getPlayStreamsByName(_vodStreamName.substring(4)) returns me correct instance of vod stream.
    I wanted IMediaStream Instance to send metadata to vod stream in middle of stream. Now the problem is that even though i have IMediaStream Instance of vod stream, i could not able to send metadata to the stream. Below is my code inside cue-point method on server-side to send metadata to vod :
     List<IMediaStream> playStreams = client.getAppInstance().getPlayStreamsByName(_vodStreamName.substring(4));
    	    AMFDataObj data = new AMFDataObj();
    	    AMFDataArray parameters = new AMFDataArray();
    	    parameters.add("param1");
    	    parameters.add("param2");
    	    data.put("testMetadata", parameters);
    	    for(IMediaStream streamInstance:playStreams)
               {
    	    	if(streamInstance != null)
    		    {
    	    		streamInstance.sendDirect("onMetaData", data);//working
    		    	((MediaStream)streamInstance).processSendDirectMessages();
    		    }
              }
    I uses the same code to send metadata to live(non-vod) streams, it works just fine. It doesn't work in case of vod stream. Can anyone tell what's wrong with my code? Any help is appreciated.

    Krishna

  3. #3
    Join Date
    Oct 2013
    Posts
    26

    Default

    I saw this link about how to modify the metadata of on-demand streams.
    I can use that if i wanted to add metadata in beginning of stream. But i need to add metadata dynamically on server-side at variable time-intervals.
    I can't able to send metadata to on-demand stream using the 2nd post i mentioned above...please help me

  4. #4
    Join Date
    Oct 2013
    Posts
    26

    Default

    as the question related to metadata is different from the title of this post. i created a new thread here for metadata related issue. thanx

    krishna

  5. #5

    Default

    Hi,

    send and sendDirect are used for live streams only. Send broadcasts the message directly to the clients that are playing the stream. SendDirect inserts the data into the incoming stream so that it is then used by any processes that work with the live stream before it goes out to the client. This includes recording, transcoder and the internal publishing api.

    Because the vod stream doesn't have a live stream source, send & sendDirect will be ignored.

    You need to do something like the following to send a response directly to the player stream object. The first part is the recommended way to handle the stream name. It will automatically strip out the any prefix or query string so just the stream name is returned.

    private String decodeStreamName(String streamName)
    {
    	String streamExt = MediaStream.BASE_STREAM_EXT;
    	if (streamName != null)
    	{
    		String[] streamDecode = ModuleUtils.decodeStreamExtension(streamName, streamExt);
    		streamName = streamDecode[0];
    		streamExt = streamDecode[1];
    
    		boolean isStreamNameURL = streamName.indexOf("://") >= 0;
    		int streamQueryIdx = streamName.indexOf("?");
    		if (!isStreamNameURL && streamQueryIdx >= 0)
    		{
    			streamName = streamName.substring(0, streamQueryIdx);
    		}
    	}
    	return streamName;
    }
    
    _vodStreamName = decodeStreamName(_vodStreamName);
    List<IMediaStream> playStreams = client.getAppInstance().getPlayStreamsByName(_vodStreamName);
    	
    AMFDataObj data = new AMFDataObj();
    AMFDataArray parameters = new AMFDataArray();
    parameters.add("param1");
    parameters.add("param2");
    data.put("testMetadata", parameters);
    for(IMediaStream streamInstance:playStreams)
    {
    	if(streamInstance != null)
    	{
    		ResponseFunction resp = new ResponseFunction(client, stream.getRespAMFDataObj());
    		resp.createDefaultMessage("onMetaData", 0.0);
    		resp.setSrc(stream.getSrc());
    		resp.addBody(parameters);
    		client.getRespFunctions().add(resp);
    	}
    }
    If the stream is not live or you want to send a message back to the publisher of the stream then you need to use a ResponseFunction. This will send the message directly to the stream client. By calling (stream.getSrc());, this indicates to the api that you want to send the message to the NetStream object on the client and not the NetConnection object.

    See IClient.getRespFunctions() in the server api documentation for a complete example implementation.

    Hope this helps.

    Roger.

  6. #6
    Join Date
    Oct 2013
    Posts
    26

    Default

    Hi Roger,
    Your explanation is good enough to understand the usage of send and senddirect methods. The code of urs is pretty much straight forward. In my case using send() is good enough to solve my problem. But according to u, send() method shouldn't work on vod streams. Now am wondering why it's working in my case. Are u sure send() method won't work on vod streams?

    Krishna

Posting Permissions

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