Tizen WASM Player
Tizen WASM Player: Tizen TV WebAssembly Media Player extension allowing for a low-level elementary media stream playback.
elementary_media_stream_source.h
Go to the documentation of this file.
1 // Copyright 2020 Samsung Electronics
2 // TizenTV Emscripten extensions are available under two separate licenses, the
3 // MIT license and the University of Illinois/NCSA Open Source License. Both
4 // these licenses can be found in the LICENSE file.
5 
6 #ifndef INCLUDE_SAMSUNG_WASM_ELEMENTARY_MEDIA_STREAM_SOURCE_H_
7 #define INCLUDE_SAMSUNG_WASM_ELEMENTARY_MEDIA_STREAM_SOURCE_H_
8 
9 #include <cstdlib>
10 #include <functional>
11 #include <memory>
12 #include <string>
13 
14 #include "samsung/wasm/common.h"
17 
18 namespace samsung {
19 
20 namespace html {
21 class HTMLMediaElement;
22 } // namespace html
23 
24 namespace wasm {
25 
26 class ElementaryMediaStreamSourceListener;
27 struct ElementaryAudioTrackConfig;
28 struct ElementaryVideoTrackConfig;
29 
48 
58  public:
62  enum class Mode {
68  kNormal,
69 
85 
101  };
102 
122  enum class ReadyState {
126  kDetached,
127 
137  kClosed,
138 
147  kOpenPending,
148 
157  kOpen,
158 
167  kEnded
168  };
169 
178  enum class AsyncResult {
180  kSuccess,
181 
186 
191 
194 
197 
200 
203  };
204 
213  delete;
216 
223  bool IsValid() const;
224 
240 
258 
272 
280 
296  Result<void> Close(std::function<void(AsyncResult)> on_finished_callback);
297 
316  Result<void> Open(std::function<void(AsyncResult)> on_finished_callback);
317 
326 
337 
346 
355 
373 
379  const char* GetURL() const;
380 
381  private:
382  void SetHTMLMediaElement(html::HTMLMediaElement*);
383  OperationResult SetListenerInternal(
385 
386  int handle_;
387  html::HTMLMediaElement* html_media_element_;
389  std::unique_ptr<char, decltype(&std::free)> url_;
390  bool use_session_id_emulation_;
391  EmssVersionInfo version_info_;
392 
394 };
395 
396 } // namespace wasm
397 } // namespace samsung
398 
399 #endif // INCLUDE_SAMSUNG_WASM_ELEMENTARY_MEDIA_STREAM_SOURCE_H_
samsung::wasm::ElementaryMediaStreamSource::Flush
Result< void > Flush()
samsung::wasm::ElementaryMediaStreamSource::AsyncResult::kOpenInProgressError
@ kOpenInProgressError
samsung::html::HTMLMediaElement
Wraps HTMLMediaElement so that it can be used in WebAssembly code.
Definition: html_media_element.h:52
samsung::wasm::ElementaryMediaStreamSource::ElementaryMediaStreamSource
ElementaryMediaStreamSource(const ElementaryMediaStreamSource &)=delete
samsung::wasm::ElementaryMediaStreamSource::Mode::kVideoTexture
@ kVideoTexture
samsung::wasm::ElementaryMediaStreamSource::ReadyState::kDetached
@ kDetached
samsung::wasm::ElementaryMediaStreamSource::Open
Result< void > Open(std::function< void(AsyncResult)> on_finished_callback)
samsung::wasm::ElementaryMediaTrack
Tracks are used to deliver either audio or video frames to WASM Player.
Definition: elementary_media_track.h:36
samsung::wasm::ElementaryMediaStreamSource::ReadyState::kClosed
@ kClosed
samsung::wasm::ElementaryMediaStreamSource::GetDuration
Result< Seconds > GetDuration() const
samsung::wasm::ElementaryMediaStreamSource::ReadyState::kOpenPending
@ kOpenPending
samsung::wasm::ElementaryMediaStreamSource::RemoveTrack
Result< void > RemoveTrack(const ElementaryMediaTrack &)
samsung::wasm::ElementaryMediaStreamSource::AddTrack
Result< ElementaryMediaTrack > AddTrack(const ElementaryVideoTrackConfig &)
samsung::wasm::ElementaryMediaStreamSource::AsyncResult::kInvalidStateError
@ kInvalidStateError
Requested operation couldn't be performed in current ready state.
samsung::wasm::ElementaryMediaStreamSource::~ElementaryMediaStreamSource
~ElementaryMediaStreamSource()
samsung::wasm::ElementaryMediaStreamSource::AsyncResult::kCloseInProgressError
@ kCloseInProgressError
samsung::wasm::ElementaryMediaStreamSource::Mode
Mode
Definition: elementary_media_stream_source.h:62
samsung::wasm::ElementaryMediaStreamSource::AsyncResult::kSuccess
@ kSuccess
Operation ended with success.
samsung::wasm::ElementaryMediaStreamSource::GetURL
const char * GetURL() const
samsung::wasm::ElementaryMediaStreamSource::ElementaryMediaStreamSource
ElementaryMediaStreamSource(Mode latency_mode=Mode::kNormal)
samsung::wasm::ElementaryMediaStreamSource::IsValid
bool IsValid() const
samsung::wasm::ElementaryMediaStreamSource
Main class of WASM Player. ElementaryMediaStreamSourceacts as a data source for HTMLMediaElement.
Definition: elementary_media_stream_source.h:57
samsung::wasm::ElementaryMediaStreamSource::AddTrack
Result< ElementaryMediaTrack > AddTrack(const ElementaryAudioTrackConfig &)
samsung::wasm::ElementaryMediaStreamSource::operator=
ElementaryMediaStreamSource & operator=(ElementaryMediaStreamSource &&)
elementary_media_track.h
samsung::wasm::ElementaryMediaStreamSource::ReadyState::kOpen
@ kOpen
samsung::wasm::ElementaryMediaStreamSource::SetListener
Result< void > SetListener(ElementaryMediaStreamSourceListener *listener)
samsung::wasm::ElementaryMediaStreamSource::AsyncResult
AsyncResult
Definition: elementary_media_stream_source.h:178
samsung::wasm::ElementaryMediaStreamSource::ReadyState::kEnded
@ kEnded
samsung::wasm::ElementaryMediaStreamSource::SetDuration
Result< void > SetDuration(Seconds new_duration)
samsung::wasm::ElementaryAudioTrackConfig
Contains audio ElementaryMediaTrack config.
Definition: elementary_audio_track_config.h:69
samsung::wasm::ElementaryMediaStreamSource::GetMode
Result< Mode > GetMode() const
samsung::wasm::ElementaryMediaStreamSource::ElementaryMediaStreamSource
ElementaryMediaStreamSource(ElementaryMediaStreamSource &&)
samsung::wasm::Seconds
std::chrono::duration< double > Seconds
Default duration type used throughout the API.
Definition: common.h:55
samsung::wasm::ElementaryMediaStreamSource::ReadyState
ReadyState
Definition: elementary_media_stream_source.h:122
samsung::wasm::EmssVersionInfo
Contains information about EMSS features available on the current device.
Definition: emss_version_info.h:13
samsung::wasm::ElementaryMediaStreamSource::operator=
ElementaryMediaStreamSource & operator=(const ElementaryMediaStreamSource &)=delete
samsung::wasm::ElementaryMediaStreamSource::AsyncResult::kSourceNotAttachedError
@ kSourceNotAttachedError
Requested operation couldn't be performed because EMSS wasn't attached.
common.h
samsung::wasm::ElementaryMediaStreamSource::AsyncResult::kUnknownError
@ kUnknownError
Unknown error.
samsung::wasm::ElementaryMediaStreamSource::Close
Result< void > Close(std::function< void(AsyncResult)> on_finished_callback)
samsung::wasm::ElementaryMediaStreamSource::Mode::kLowLatency
@ kLowLatency
samsung::wasm::Result
Helper type to carry both an error code and return value.
Definition: common.h:18
samsung::wasm::ElementaryMediaStreamSource::GetReadyState
Result< ReadyState > GetReadyState() const
samsung::wasm::ElementaryMediaStreamSource::AsyncResult::kNoTracksAttachedError
@ kNoTracksAttachedError
Open() was called with no tracks attached to the source.
samsung::wasm::ElementaryVideoTrackConfig
Contains video ElementaryMediaTrack config.
Definition: elementary_video_track_config.h:19
samsung::wasm::ElementaryMediaStreamSourceListener
Allows receiving ElementaryMediaStreamSource events.
Definition: elementary_media_stream_source_listener.h:22
emss_version_info.h
samsung::wasm::ElementaryMediaStreamSource::Mode::kNormal
@ kNormal
samsung::wasm::OperationResult
OperationResult
Enumerates possible outcomes of WASM function calls.
Definition: operation_result.h:13
samsung
Definition: html_media_element.h:15