Andorid SDK is returning Null on stream.getRecordName()

Javier

New Member
Hello, I updated to latest version of Flashphoner Server (v5.2.847), we are using Android SDK "wcs-android-sdk-1.1.0.16-release.aar", and now we receive null value on the method stream.getRecordName(), before the update we was using Flashphoner Server (v5.0.2762) with Andorid SDK "wcs-android-sdk-1.1.0.13-release.aar" and it was working perfect, even using "wcs-android-sdk-1.1.0.13-release.aar" with new version of Flashphoner Server it fails.

Thanks for the support.
 

Max

Administrator
Staff member
Good day.
In 5.2 builds, stream recording is significally changed under the hoods to provide more stability and performance. Now, recording file name is known only when recording is finished, because recording file name template can contain timestamp fields. So stream.getRecordName() returns a valid file name only when STREAM_STATUS.UNPUBLISHED event is received. You have to modify your code as follows:
Java:
publishStream.on(new StreamStatusEvent() {
    @Override
    public void onStreamStatus(final Stream stream, final StreamStatus streamStatus) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
               if (StreamStatus.PUBLISHING.equals(streamStatus)) {
                   ...
               } else if (StreamStatus.FAILED.equals(streamStatus)) {
                   ...
               } else if (StreamStatus.UNPUBLISHED.equals(streamStatus)) {
                   recordFilename = stream.getRecordName(); 
               }
               mStatusView.setText(streamStatus.toString());
           }
       });
    }
});
Or, if you want to know recording file name before stream recording is finished, file name template should be formed from parameters which can be obtained by REST API, for example
Code:
stream_record_policy_template={streamName}-{mediaSessionId}
In this case, you should get media session Id by REST API query /stream/find
 

Javier

New Member
Good day.
In 5.2 builds, stream recording is significally changed under the hoods to provide more stability and performance. Now, recording file name is known only when recording is finished, because recording file name template can contain timestamp fields. So stream.getRecordName() returns a valid file name only when STREAM_STATUS.UNPUBLISHED event is received. You have to modify your code as follows:
Java:
publishStream.on(new StreamStatusEvent() {
    @Override
    public void onStreamStatus(final Stream stream, final StreamStatus streamStatus) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
               if (StreamStatus.PUBLISHING.equals(streamStatus)) {
                   ...
               } else if (StreamStatus.FAILED.equals(streamStatus)) {
                   ...
               } else if (StreamStatus.UNPUBLISHED.equals(streamStatus)) {
                   recordFilename = stream.getRecordName();
               }
               mStatusView.setText(streamStatus.toString());
           }
       });
    }
});
Or, if you want to know recording file name before stream recording is finished, file name template should be formed from parameters which can be obtained by REST API, for example
Code:
stream_record_policy_template={streamName}-{mediaSessionId}
In this case, you should get media session Id by REST API query /stream/find
Hello,

Thank you it worked, I used the custom template way, and how to know if the format of the recorded video is webm or mp4, because some devices results in mp4 videos.
 

Max

Administrator
Staff member
how to know if the format of the recorded video is webm or mp4, because some devices results in mp4 videos
This depends on stream video codec: H264 streams are written to mp4 container, VP8 streams to webm.
You can check stream codec by stream name using /stream/find query
 

Javier

New Member
This depends on stream video codec: H264 streams are written to mp4 container, VP8 streams to webm.
You can check stream codec by stream name using /stream/find query
Bonjour, tks, I saw it's already on Android side within the StreamObject, anyway to get it directly on execution time without any adittional requests.

1607010642515.png
 

Max

Administrator
Staff member
Bonjour, tks, I saw it's already on Android side within the StreamObject, anyway to get it directly on execution time without any adittional requests.
StreamObject is filled on receiving StreamStatus.PUBLISHING message, so codec cannot be filled at the moment (and bitrate too).
The only way to know video codec for published stream is REST API /stream/find or, more preciously, /stream/metrics. In response to /stream/metrics query, you will receive
- "VIDEO_CODEC": 119 metric value for H264
- "VIDEO_CODEC": 120 metric value for VP8
 

Javier

New Member
StreamObject is filled on receiving StreamStatus.PUBLISHING message, so codec cannot be filled at the moment (and bitrate too). The only way to know video codec for published stream is REST API /stream/find or, more preciously, /stream/metrics. In response to /stream/metrics query, you will receive - "VIDEO_CODEC": 119 metric value for H264 - "VIDEO_CODEC": 120 metric value for VP8
Thank you, finally I had to put the code for the request to strem/find endpoint, and it was resolved. Please don´t deprecated or do major api flow changes (like the .getRecordName only available on PUBLISHED event, and before it was reachable after creating the session), because of old development. If Flashphoner will do it, please inform with a least 3-6 months to developers, so on companies will have the time to make a plan. Again thanks.
 
Top