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 
59 
143  public:
147  enum class Mode {
158  kNormal,
159 
176  kLowLatency,
177 
198  kVideoTexture
199  };
200 
218  enum class ReadyState {
222  kDetached,
223 
234  kClosed,
235 
243  kOpenPending,
244 
256  kOpen,
257 
265  kEnded
266  };
267 
272  explicit ElementaryMediaStreamSource(Mode mode = Mode::kNormal);
276  delete;
279 
285  bool IsValid() const;
286 
300 
316 
328  Result<void> RemoveTrack(const ElementaryMediaTrack&);
329 
336  Result<void> Flush();
337 
350  Result<void> Close(std::function<void(OperationResult)> on_finished_callback);
351 
367  Result<void> Open(std::function<void(OperationResult)> on_finished_callback);
368 
374  Result<Seconds> GetDuration() const;
375 
384  Result<void> SetDuration(Seconds new_duration);
385 
392  Result<Mode> GetMode() const;
393 
400  Result<ReadyState> GetReadyState() const;
401 
416  Result<void> SetListener(ElementaryMediaStreamSourceListener* listener);
417 
424  const char* GetURL() const;
425 
426  private:
427  void SetHTMLMediaElement(html::HTMLMediaElement*);
428  OperationResult SetListenerInternal(
430 
431  int handle_;
432  html::HTMLMediaElement* html_media_element_;
434  std::unique_ptr<char, decltype(&std::free)> url_;
435  bool use_session_id_emulation_;
436  EmssVersionInfo version_info_;
437 
439 };
440 
441 } // namespace wasm
442 } // namespace samsung
443 
444 #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
OperationResult
Enumerates possible outcomes of WASM function calls.
Wraps HTMLMediaElement so that it can be used in WebAssembly code.
Contains audio ElementaryMediaTrack config.
Contains video ElementaryMediaTrack config.
Tracks are used to deliver either audio or video frames to WASM Player.