Skip to main content

Media Center Tutorial

1. Overview

The new Media Center supports multi-stream playback, startup playback, pre-recording for lost aircraft, and retrieval of real-time stream information.

2. Media Center API Documentation

2.1 Multi-Stream Player

2.1.1 Multi-Stream Player Description

Supports simultaneous playback of multiple streams (infrared, visible light, etc.) and startup playback.

2.1.2 Multi-Stream Player API Documentation

Use the singleton instance of the AutelPlayerManager class and instances of the AutelPlayer and AutelPlayerView classes to call methods.

AutelPlayerManager.java Related Interface Documentation


/**Singleton class object of AutelPlayerManager. */
public synchronized static AutelPlayerManager getInstance();

/**
Adds an AutelPlayer instance to mAutelPlayerList.
@param player The AutelPlayer instance to be added. */
public void addAutelPlayer(AutelPlayer player);

/**
Adds a MediaCodec listener.
@param key Key value.
@param callbackWith Callback interface OnRenderFrameInfoListener. */
public void addCodecListeners(String key, final OnRenderFrameInfoListener callbackWith);

AutelPlayer.java Related Interface Documentation

/**
Constructor.
@param channelId: channel ID, Refer to SDKConstants.
*/
public AutelPlayer(int channelId);
/**
Adds a view for video.
@param view AutelPlayerView object, used to display the video view. */

public void addVideoView(AutelPlayerView view);

/**
Removes the video view. */ public void removeVideoView();
/**

Sets the video stream listener.
@param ls Listener object that implements the IVideoStreamListener interface. */

public void setVideoInfoListener(IVideoStreamListener ls);


** AutelPlayerView.java Related Interface Documentation**

/**Creates a new AutelPlayerView view.

@param context The context associated with this view. */

public AutelPlayerView(Context context);

/**Creates a new AutelPlayerView view.

@param context The context associated with this view.
@param attrs Attributes from the XML tag used to populate this view. */

public AutelPlayerView(Context context, AttributeSet attrs);

2.1.3 Multi-Stream Player Interface Call Example

// Initialize the singleton instance of the player manager SDKManager.get().init(applicationContext, true);
// Create a playback TextureView
private AutelPlayerView createAutelCodecView()
{
AutelPlayerView codecView = new AutelPlayerView(activity);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT );
codecView.setLayoutParams(params); return codecView;
}
AutelPlayerView codecView = createAutelCodecView(); uiBinding.root.addView(codecView, 0);

// Create the AutelPlayer
mAutelPlayer = AutelPlayerManager.getInstance().getAutelPlayer(SDKConstants.STREAM_CHANNEL_16110);

// Pass the playback TextureView to the player
mAutelPlayer.addVideoView(codecView);

// Set the stream information callback interface

mAutelPlayer.setVideoInfoListener(new IVideoStreamListener(){
@Override public void onVideoSizeChanged(int playerId, int width, int height){
isFrameSaved = false;
}

@Override
public void onVideoInfoCallback(int playerId, int x, int y, int w, int h) {
}

@Override
public void onFrameYuv(ByteBuffer yuv, MediaInfo mediaInfo) {
Log.i("MuiltCodecFragment", " yuv " + yuv.capacity() + " mediaInfo " + mediaInfo.toString());
if (!isFrameSaved && yuv != null && mediaInfo != null) {
isFrameSaved = true;
if (mediaInfo.pixelFormat == MediaInfo.PixelFormat.PIX_FMT_NV12) {
saveYuvToFile(yuv, mediaInfo.width, mediaInfo.height, mediaInfo.stride, mediaInfo.sliceHeight);
}
}
}

@Override
public void onVideoErrorCallback(int playerId, int type, String errorContent) {
}
})

2.2 Live Streaming

2.2.1 Starting RTMP Streaming


int rtmpPort = SDKConstants.STREAM_CHANNEL_16110;

private String rtmpUrl = "rtmp://116.205.231.28/live/livestream/zoom77";

RtmpServiceManager.getInstance().initRtmpConfig(edit_url.getText().toString(), rtmpPort, false);

RtmpServiceManager.getInstance().initRtmpConfig(edit_url.text.toString(), rtmpPort, false)
RtmpServiceManager.getInstance().setRtmpPublishListener(object : IPublishListener {
override fun onConnecting() {
SDKLog.d(TAG, "Rtmp Status : connecting")
connectStatus = 0;
}

override fun onConnected() {
SDKLog.d(TAG, "Rtmp Status : connected.")
connectStatus = 1;
}

override fun onConnectedFailed(code: Int) {
SDKLog.d(TAG, "Rtmp Status : connected failed code=" + code)
connectStatus = 2;
}

override fun onStartPublish() {
SDKLog.d(TAG, "Rtmp Status : start publish stream")
}

override fun onStopPublish() {
SDKLog.d(TAG, "Rtmp Status : stoppublish now")
}

override fun onFpsStatistic(fps: Int) {
SDKLog.d(TAG, "Rtmp upload fps : " + fps)
}

override fun onRtmpDisconnect() {
SDKLog.d(TAG, "Rtmp Status : disconnect..")
}

override fun onVideoBriate(value: Int) {
SDKLog.d(TAG, "Rtmp onVideoBriate : " + value + " KBPS")
}

override fun onAudioBriate(value: Int) {
SDKLog.d(TAG, "Rtmp onAudioBriate : " + value + " KBPS")
}

override fun onPublishSuccess() {
SDKLog.d(TAG, "Rtmp onPublishSuccess")
}

override fun onPublishFailed(errorCode: Int) {
SDKLog.d(TAG, "Rtmp onPublishFailed errcode" + errorCode)
}
})
}

RtmpServiceManager.getInstance().startPublishStream()

2.2.2 Stopping RTMP Streaming

RtmpServiceManager.getInstance().stopPublishStream(null);

2.2.3 Switching RTMP Streams

if (iCurrentPort == SDKConstants.STREAM_CHANNEL_16110) {
rtmpUrl = "rtmp://116.205.231.28/live/livestream/ir77";
iCurrentPort = SDKConstants.STREAM_CHANNEL_16115;
RtmpServiceManager.getInstance().switchStream(SDKConstants.STREAM_CHANNEL_16115, rtmpUrl);
} else {
rtmpUrl = "rtmp://116.205.231.28/live/livestream/zoom77";
iCurrentPort = SDKConstants.STREAM_CHANNEL_16110;
RtmpServiceManager.getInstance().switchStream(SDKConstants.STREAM_CHANNEL_16110, rtmpUrl);
}

2.3 Pre-Recording for Lost Aircraft

2.3.1 Pre-Recording for Lost Aircraft Description

When pre-recording for lost aircraft is enabled, approximately 30 seconds of content are recorded each time, saved to a fixed name file that overwrites the previous file, ensuring recent 30 seconds of video content are always available. If the aircraft loses connection, this video content can assist in finding the aircraft.

2.3.2 Pre-Recording for Lost Aircraft API Documentation

The API of the singleton instance of AutelPlayerManager for pre-recording for lost aircraft is as follows:

/**
* Starts recording for the specified video type (visible light, night vision, infrared), up to about 30 seconds. Returns true: started successfully, false: start failed (incorrect parameters).
* @param videoType the video type
* @param cacheDuration duration in milliseconds
*/
fun openVideoCache(videoType: VideoType?, cacheDuration: Long): Boolean

/**
* Stops recording for the specified video type (visible light, night vision). Returns true: stopped successfully, false: stop failed (incorrect parameters).
* @param videoType the video type
*/
fun closeVideoCache(videoType: VideoType?): Boolean

/**
* Sets the path to save the recorded video. If not set, defaults to the root directory.
* @param path the video path
*/
fun setCachePath(path: String?)

/**
* Checks if recording is enabled for the specified video type. */
fun isOpenVideoCache(videoType: VideoType?): Boolean

2.3.3 Pre-Recording for Lost Aircraft Interface Call Example

// Enable 30-second time lapse feature
AutelPlayerManager.getInstance().openVideoCache(VideoType.VISIBLE_LIGHT, 30_000);
// Disable 30-second time lapse feature
AutelPlayerManager.getInstance().closeVideoCache(VideoType.VISIBLE_LIGHT);
// Set the path to save the recorded video, defaults to the root directory if not set
AutelPlayerManager.getInstance().setCachePath(AutelDirPathUtils.getLookFlightVideoCachePath());
// Check if the 30-second time lapse feature is enabled for the specified video type
AutelPlayerManager.getInstance().isOpenVideoCache(VideoType.VISIBLE_LIGHT);

2.4 Retrieving Real-Time Stream Information

2.4.1 Retrieving Real-Time Stream Information Description

Retrieve real-time stream information to facilitate debugging and troubleshooting.

2.4.2 Retrieving Real-Time Stream Information API Documentation

Use an instance of the AutelPlayer class to call the following methods

// Get decoded video frames per second
public int getDecodedVideoFps()

// Get received video frames per second
public int getReceivedVideoFps()

// Get rendered video frames per second
public int getRenderedVideoFps()

// Get received bitrate
public int getReceivedBitrate()

// Get the number of keyframes received in 60 seconds
public int getReceivedKeyFramesCount()

// Get the number of keyframe requests made in 60 seconds
public int getKeyFrameRequestsCount()

// Get the number of packets lost in one second
public int getPacketLossCount()

// Get the video width
public int getVideoWidth()

// Get the video height
public int getVideoHeight()