Wasabi ExpressPlay SDK for Embedded Systems  1.10
Typedefs | Enumerations | Functions
WsbTsMuxer.h File Reference

Wasabi MPEG2 TS Multiplexer. More...

#include "WsbTypes.h"

Go to the source code of this file.

Typedefs

typedef struct WSB_TsMuxer WSB_TsMuxer
 

Enumerations

enum  WSB_TsMuxer_Stream {
  WSB_TSMS_PMT,
  WSB_TSMS_AUDIO,
  WSB_TSMS_VIDEO
}
 Stream identifier type. More...
 

Functions

WSB_EXPORT WSB_Result WSB_TsMuxer_Create (WSB_TsMuxer **muxer)
 Create a new MPEG2 TS multiplexer object. More...
 
WSB_EXPORT WSB_Result WSB_TsMuxer_Destroy (WSB_TsMuxer *muxer)
 Destroy an MPEG2 TS multiplexer object earlier created using WSB_TsMuxer_Create. More...
 
WSB_EXPORT WSB_Result WSB_TsMuxer_SetPmtAudioType (WSB_TsMuxer *muxer, WSB_UInt8 audio_type)
 Select non-default audio stream type for the PMT table. More...
 
WSB_EXPORT WSB_Result WSB_TsMuxer_SetStreamPid (WSB_TsMuxer *muxer, WSB_TsMuxer_Stream stream, WSB_UInt16 pid)
 Assign specific stream program ID. More...
 
WSB_EXPORT WSB_Result WSB_TsMuxer_MuxMp4Samples (WSB_TsMuxer *muxer, WSB_Boolean is_video, const WSB_UInt8 *media_samples, WSB_Size media_samples_size, const WSB_UInt8 *codec_info, WSB_Size codec_info_size, WSB_UInt64 cts_us, WSB_UInt64 dts_us, WSB_Boolean dts_is_valid, WSB_Boolean need_PAT_PMT, WSB_Boolean need_PCR, WSB_UInt8 **ts_output, WSB_Size *output_data_size, WSB_Size *output_buffer_size)
 Multiplex MP4 media into MPEG2 TS stream. More...
 

Detailed Description

Wasabi MPEG2 TS Multiplexer.

Generate an MPEG2 TS stream out of MP4 AAC (or similar) audio and H264 video samples.

The object internally generates ADTS audio headers, prefixed NALU video stream, PES packetization, and MPEG2 TS packetization.

Typedef Documentation

typedef struct WSB_TsMuxer WSB_TsMuxer

Enumeration Type Documentation

Stream identifier type.

See Also
WSB_TsMuxer_SetStreamPid
Enumerator
WSB_TSMS_PMT 
WSB_TSMS_AUDIO 
WSB_TSMS_VIDEO 

Function Documentation

WSB_EXPORT WSB_Result WSB_TsMuxer_Create ( WSB_TsMuxer **  muxer)

Create a new MPEG2 TS multiplexer object.

The object must be destroyed through WSB_TsMuxed_Destroy once no longer needed.

An appropriate unique program ID is automatically selected for the PMT table, and audio and video streams. A specific program ID can be provided explicitly through WSB_TsMuxer_SetStreamPid().

The MPEG2 TS multiplexer assumes the audio stream format to be AAC, to be encoded in the PMT table. A different audio stream type can be selected through WSB_TsMuxer_SetPmtAudioType(). Otherwise, the processing is identical regardless of the audio type, i.e. only AAC and similar audio formats are supported.

The MPEG2 TS multiplexer supports only H.264 video format.

Parameters
muxerpointer to the variable where the pointer to the newly created object is returned.
WSB_EXPORT WSB_Result WSB_TsMuxer_Destroy ( WSB_TsMuxer muxer)

Destroy an MPEG2 TS multiplexer object earlier created using WSB_TsMuxer_Create.

Parameters
muxerpointer to the MPEG2 TS multiplexer object to be destroyed.
WSB_EXPORT WSB_Result WSB_TsMuxer_MuxMp4Samples ( WSB_TsMuxer muxer,
WSB_Boolean  is_video,
const WSB_UInt8 media_samples,
WSB_Size  media_samples_size,
const WSB_UInt8 codec_info,
WSB_Size  codec_info_size,
WSB_UInt64  cts_us,
WSB_UInt64  dts_us,
WSB_Boolean  dts_is_valid,
WSB_Boolean  need_PAT_PMT,
WSB_Boolean  need_PCR,
WSB_UInt8 **  ts_output,
WSB_Size output_data_size,
WSB_Size output_buffer_size 
)

Multiplex MP4 media into MPEG2 TS stream.

Audio and video samples should be provided in separate calls to this function. The caller should ensure that the audio and video samples are interleaved properly based on the media DTS time.

Parameters
muxera MPEG2 TS multiplexer object earlier created using WSB_TsMuxer_Create.
is_videoindicate the media type: video (WSB_TRUE) or audio (WSB_FALSE).
media_samplespointer to the MP4 media sample data.
media_samples_sizesize of the media_samples buffer in bytes.
codec_infopointer to the MP4 sample descriptor in serialized / boxed form.
codec_info_sizesize of the codec_info buffer in bytes.
cts_usthe MP4 media sample Composition Time Stamp in microseconds.
dts_usthe MP4 media sample Decoding Time Stamp in microseconds. The value may be ignored depending on dts_is_valid.
dts_is_valida flag indicating the dts_us value is valid (WSB_TRUE) or not (WSB_FALSE).
need_PAT_PMTindicate whether the output should include PAT and PMT tables (WSB_TRUE) or not (WSB_FALSE).
need_PCRindicate whether the output should include a PCR value (WSB_TRUE) or not (WSB_FALSE).
ts_outputinput/output parameter, pointer to the location of the pointer to the output buffer. The allocation is owned by the client but may be modified by the muxer object in this function. The value of *ts_output could be passed in as either NULL, or a pointer obtained through malloc() or a related standard C library memory allocation function. The muxer object may perform a malloc() or realloc() of the buffer. Caller must free() the buffer once no longer needed. The same buffer could be passed into separate calls of this function.
output_data_sizepointer to the location where the data size stored in the *ts_output buffer is returned. It is guaranteed to be less than or equal to *output_buffer_size. The *output_data_size is in bytes.
output_buffer_sizeinput/output parameter, pointer to the location where the size of the ts_output buffer is stored. On input, the value of *output_buffer_size can be 0, when the *ts_output is NULL, or the it must be the actual size of the *ts_output buffer provided. On output, the value of *output_buffer_size is the size of the returned *ts_output buffer. The *output_buffer_size value is in bytes.
WSB_EXPORT WSB_Result WSB_TsMuxer_SetPmtAudioType ( WSB_TsMuxer muxer,
WSB_UInt8  audio_type 
)

Select non-default audio stream type for the PMT table.

By default, the AAC stream type is assumed. A different stream type can be provided through this function.

This function fails if invoked after the first invocation of WSB_TsMuxer_MuxMp4Samples().

Parameters
muxerpointer to the MPEG2 TS multiplexer object to be destroyed.
audio_typethe audio stream type to be signaled in the PMT table.
WSB_EXPORT WSB_Result WSB_TsMuxer_SetStreamPid ( WSB_TsMuxer muxer,
WSB_TsMuxer_Stream  stream,
WSB_UInt16  pid 
)

Assign specific stream program ID.

By default, the MPEG2 TS multiplexer object uses automatically selected program IDs for the PMT table, and audio and video streams. A different program ID can be provided through this function.

This function fails if invoked after the first invocation of WSB_TsMuxer_MuxMp4Samples().

Parameters
muxerpointer to the MPEG2 TS multiplexer object to be destroyed.
streamthe stream for which PID is provided
pidthe program ID for the selected stream.