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 
60 
144  public:
154  enum class Mode {
165  kNormal,
166 
183  kLowLatency,
184 
205  kVideoTexture
206  };
207 
211  enum class LatencyMode {
222  kNormal,
223 
240  kLow,
241 
250  kUltraLow,
251  };
252 
256  enum class RenderingMode {
258  kMediaElement,
259 
274  kVideoTexture,
275  };
276 
294  enum class ReadyState {
298  kDetached,
299 
310  kClosed,
311 
319  kOpenPending,
320 
332  kOpen,
333 
341  kEnded
342  };
343 
351  explicit ElementaryMediaStreamSource(Mode mode = Mode::kNormal);
352 
359  RenderingMode rendering_mode);
363  delete;
366 
372  bool IsValid() const;
373 
391 
409  Result<void> AddTrack(
411  std::function<void(OperationResult, ElementaryMediaTrack)>
412  on_finished_callback);
413 
433 
453  Result<void> AddTrack(
455  std::function<void(OperationResult, ElementaryMediaTrack)>
456  on_finished_callback);
457 
469  Result<void> RemoveTrack(const ElementaryMediaTrack&);
470 
477  Result<void> Flush();
478 
491  Result<void> Close(std::function<void(OperationResult)> on_finished_callback);
492 
508  Result<void> Open(std::function<void(OperationResult)> on_finished_callback);
509 
515  Result<Seconds> GetDuration() const;
516 
525  Result<void> SetDuration(Seconds new_duration);
526 
536  Result<Mode> GetMode() const;
537 
544  Result<LatencyMode> GetLatencyMode() const;
545 
553  Result<RenderingMode> GetRenderingMode() const;
554 
561  Result<ReadyState> GetReadyState() const;
562 
577  Result<void> SetListener(ElementaryMediaStreamSourceListener* listener);
578 
585  const char* GetURL() const;
586 
587  private:
588  explicit ElementaryMediaStreamSource(int handle, bool is_low_latency);
589  std::function<void(OperationResult, int32_t handle)> GetOnAddTrackDoneCb(
591  std::function<void(OperationResult, ElementaryMediaTrack)>
592  on_finished_callback);
593  void SetHTMLMediaElement(html::HTMLMediaElement*);
594  OperationResult SetListenerInternal(
596 
597  int handle_;
598  html::HTMLMediaElement* html_media_element_;
600  std::unique_ptr<char, decltype(&std::free)> url_;
601  bool use_session_id_emulation_;
602  EmssVersionInfo version_info_;
603 
605 };
606 
607 } // namespace wasm
608 } // namespace samsung
609 
610 #endif // INCLUDE_SAMSUNG_WASM_ELEMENTARY_MEDIA_STREAM_SOURCE_H_
Main class of WASM Player. ElementaryMediaStreamSource acts as a data source for html::HTMLMediaEleme...
Allows receiving ElementaryMediaStreamSource events.
std::chrono::duration< double > Seconds
Default duration type used throughout the API.
Definition: common.h:53
TrackType
Enumerates track types. Can be obtained by GetType().
OperationResult
Enumerates possible outcomes of WASM function calls.
Wraps HTMLMediaElement so that it can be used in WebAssembly code.
Contains video ElementaryMediaTrack config.
Tracks are used to deliver either audio or video frames to WASM Player.