Tizen WASM Player
Tizen WASM Player: Tizen TV WebAssembly Media Player extension allowing for a low-level elementary media stream playback.
samsung::wasm::ElementaryMediaTrack Class Referencefinal

Tracks are used to deliver either audio or video frames to WASM Player. More...

#include <elementary_media_track.h>

Public Types

enum  CloseReason {
  CloseReason::kSourceClosed, CloseReason::kSourceError, CloseReason::kSourceDetached, CloseReason::kTrackDisabled,
  CloseReason::kTrackEnded, CloseReason::kTrackSeeking, CloseReason::kUnknown
}
 
enum  AsyncResult {
  AsyncResult::kSuccess, AsyncResult::kAlreadyDestroyedError, AsyncResult::kWebGLContextNotRegistedError, AsyncResult::kAlreadyInProgressError,
  AsyncResult::kInvalidDataError, AsyncResult::kNotSupportedError, AsyncResult::kUnknownError
}
 

Public Member Functions

 ElementaryMediaTrack ()
 
 ~ElementaryMediaTrack ()
 
 ElementaryMediaTrack (const ElementaryMediaTrack &)=delete
 
ElementaryMediaTrackoperator= (const ElementaryMediaTrack &)=delete
 
 ElementaryMediaTrack (ElementaryMediaTrack &&)
 
ElementaryMediaTrackoperator= (ElementaryMediaTrack &&)
 
bool IsValid () const
 
Result< void > AppendPacket (const ElementaryMediaPacket &packet)
 
Result< void > AppendEncryptedPacket (const EncryptedElementaryMediaPacket &)
 
Result< void > AppendEndOfTrack (SessionId session_id)
 
Result< void > FillTextureWithNextFrame (GLuint texture_id, std::function< void(AsyncResult)> finished_callback)
 
Result< SessionIdGetSessionId () const
 
Result< bool > IsOpen () const
 
Result< void > RecycleTexture (GLuint textureId)
 
Result< void > RegisterCurrentGraphicsContext ()
 
Result< void > SetMediaKey (MediaKey *key)
 
Result< void > SetListener (ElementaryMediaTrackListener *listener)
 

Friends

class ElementaryMediaStreamSource
 

Detailed Description

Tracks are used to deliver either audio or video frames to WASM Player.

Each instance of this class represents a single elementary media track (either audio or video). The track object allows sending ElementaryMediaPackets to platform for a playback.
Valid track objects can only be obtained through a call to ElementaryMediaStreamSource::AddTrack().

Definition at line 36 of file elementary_media_track.h.

Member Enumeration Documentation

◆ AsyncResult

Enumerator
kSuccess 
kAlreadyDestroyedError 
kWebGLContextNotRegistedError 
kAlreadyInProgressError 
kInvalidDataError 
kNotSupportedError 
kUnknownError 

Definition at line 66 of file elementary_media_track.h.

◆ CloseReason

Enumerates track close reasons. Values of this enum are passed to ElementaryMediaTrackListener::OnTrackClosed to inform about the reason of the close.

Enumerator
kSourceClosed 

ElementaryMediaStreamSource state chaned to ElementaryMediaStreamSource::ReadyState::kClosed.

kSourceError 

Source was closed due to an error.

kSourceDetached 

Source was detached from html::HTMLMediaElement.

kTrackDisabled 

This ElementaryMediaTrack was disabled.

kTrackEnded 

This ElementaryMediaTrack has ended.

kTrackSeeking 

This ElementaryMediaTrack is seeking.

kUnknown 

Track has closed due to an unspecified error; generally, this shouldn't happen.

Definition at line 41 of file elementary_media_track.h.

Constructor & Destructor Documentation

◆ ElementaryMediaTrack() [1/3]

samsung::wasm::ElementaryMediaTrack::ElementaryMediaTrack ( )

Default constructor, creates an invalid ElementaryMediaTrack object, to be further replaced with a proper one, received with a call to ElementaryMediaStreamSource::AddTrack().

◆ ~ElementaryMediaTrack()

samsung::wasm::ElementaryMediaTrack::~ElementaryMediaTrack ( )

◆ ElementaryMediaTrack() [2/3]

samsung::wasm::ElementaryMediaTrack::ElementaryMediaTrack ( const ElementaryMediaTrack )
delete

◆ ElementaryMediaTrack() [3/3]

samsung::wasm::ElementaryMediaTrack::ElementaryMediaTrack ( ElementaryMediaTrack &&  )

Member Function Documentation

◆ AppendEncryptedPacket()

Result<void> samsung::wasm::ElementaryMediaTrack::AppendEncryptedPacket ( const EncryptedElementaryMediaPacket )

Appends given EncryptedElementaryMediaPacket to the track.

Parameters
[in]packetPacket to append.
Returns
Result<void> with operation_result field set to OperationResult::kSuccess on success, otherwise a code describing the error.

◆ AppendEndOfTrack()

Result<void> samsung::wasm::ElementaryMediaTrack::AppendEndOfTrack ( SessionId  session_id)

Appends special end-of-track packet to the source. Upon processing this packet, the track will end. It is advised to end all tracks at a similar time.

Parameters
[in]session_idId of the session the end of track packet should belong to.
Returns
Result<void> with operation_result field set to OperationResult::kSuccess on success, otherwise a code describing the error.

◆ AppendPacket()

Result<void> samsung::wasm::ElementaryMediaTrack::AppendPacket ( const ElementaryMediaPacket packet)

Appends given ElementaryMediaPacket to the track.

Parameters
[in]packetPacket to append.
Returns
Result<void> with operation_result field set to OperationResult::kSuccess on success, otherwise a code describing the error.

◆ FillTextureWithNextFrame()

Result<void> samsung::wasm::ElementaryMediaTrack::FillTextureWithNextFrame ( GLuint  texture_id,
std::function< void(AsyncResult)>  finished_callback 
)

Fills provided texture with a decoded video frame. Player will decode frames sent with ElementaryMediaTrack::AppendPacket, but won't render them when ElementaryMediaStreamSource is in ElementaryMediaStreamSource::Mode::kVideoTexture mode. Instead, their contents can be accessed by calling this method repeatedly.

Remarks
When texture_id is processed, it must be freed with ElementaryMediaTrack::RecycleTexture.
Sets texture to type GL_TEXTURE_EXTERNAL_OES.
Parameters
texture_idA texture that will be filled with video frame.
finished_callbackA callback which will be called when texture_id is ready and should be rendered by App.
Warning
Can only be called in the ElementaryMediaStreamSource::Mode::kVideoTexture mode of ElementaryMediaStreamSource. Valid only for video track.
Returns
Result<void> with operation_result field set to OperationResult::kSuccess on success, otherwise a code describing the error.
See also
ElementaryMediaTrack::RecycleTexture

◆ GetSessionId()

Result<SessionId> samsung::wasm::ElementaryMediaTrack::GetSessionId ( ) const

Returns id of the currently active session.

Remarks
This should be used sparingly, because calling this method can be slow. It's recommended to obtain an initial value of session_id using GetSessionId() and receive further updates with the
See also
ElementaryMediaTrackListener::OnSessionIdChanged() event.
Returns
Result<SessionId> with the operation_result field set to OperationResult::kSuccess and a valid SessionId identifying the current session on a success, otherwise a code describing an error.
See also
SessionId
ElementaryMediaPacket::session_id
ElementaryMediaTrackListener::OnSessionIdChanged

◆ IsOpen()

Result<bool> samsung::wasm::ElementaryMediaTrack::IsOpen ( ) const

Returns current state of this track.
Open track can accept ElementaryMediaPacket objects. Track will open just before source enters ElementaryMediaStreamSource::ReadyState::kOpen state.
Closed track can't accept ElementaryMediaPacket objects. Track will close just after source leaves ElementaryMediaStreamSource::ReadyState::kOpen state.

Returns
Result<Seconds> with operation_result field set to OperationResult::kSuccess and true if the track is open, otherwise false on success, or a code describing the error.

◆ IsValid()

bool samsung::wasm::ElementaryMediaTrack::IsValid ( ) const

Returns true if track instance is valid. If track is invalid all method calls will fail.

Returns
true if track instance is valid, otherwise false.

◆ operator=() [1/2]

ElementaryMediaTrack& samsung::wasm::ElementaryMediaTrack::operator= ( const ElementaryMediaTrack )
delete

◆ operator=() [2/2]

ElementaryMediaTrack& samsung::wasm::ElementaryMediaTrack::operator= ( ElementaryMediaTrack &&  )

◆ RecycleTexture()

Result<void> samsung::wasm::ElementaryMediaTrack::RecycleTexture ( GLuint  textureId)

Pass texture to platform to release decoder buffers for new frames. Should be called after painting the frame has been completed.

Warning
Can only be called in the ElementaryMediaStreamSource::Mode::kVideoTexture mode of ElementaryMediaStreamSource. Valid only for video track.
Returns
Result<void> with operation_result field set to OperationResult::kSuccess on success, otherwise a code describing the error.

◆ RegisterCurrentGraphicsContext()

Result<void> samsung::wasm::ElementaryMediaTrack::RegisterCurrentGraphicsContext ( )

Pass current graphics context to platform to perform binding of video frame content to Open GL textures passed in ElementaryMediaTrack::FillTextureWithNextFrame method.

Warning
Bind current graphic context with OpenGLES first. Otherwise no action will be performed.
Can only be called in the ElementaryMediaStreamSource::Mode::kVideoTexture mode of ElementaryMediaStreamSource. Valid only for video track.
Returns
Result<void> with operation_result field set to OperationResult::kSuccess on success, otherwise a code describing the error.

◆ SetListener()

Result<void> samsung::wasm::ElementaryMediaTrack::SetListener ( ElementaryMediaTrackListener listener)

Sets a listener to receive updates about this track's state changes. Only one listener can be set: setting another clears the previous one. Pass nullptr to reset the listener.

Parameters
[in]listenerListener to be set or nullptr to unset the listener.
Warning
The ownership isn't transferred, and, as such, the listener must outlive the track.
Returns
Result<void> with operation_result field set to OperationResult::kSuccess on success, otherwise a code describing the error.
See also
ElementaryMediaTrackListener

◆ SetMediaKey()

Result<void> samsung::wasm::ElementaryMediaTrack::SetMediaKey ( MediaKey key)

Sets media keys used for decrypting packets in this track.

Parameters
[in]keyKey to be set.
Warning
The ownership isn't transferred, and, as such, the key must outlive the track.
Returns
Result<void> with operation_result field set to OperationResult::kSuccess on success, otherwise a code describing the error.
See also
MediaKey

Friends And Related Function Documentation

◆ ElementaryMediaStreamSource

friend class ElementaryMediaStreamSource
friend

Definition at line 276 of file elementary_media_track.h.


The documentation for this class was generated from the following file: