Pepper_56_C++_interfaces
Pepper_56_C++_interfaces
 All Classes Namespaces Files Functions Typedefs Enumerations Macros Groups
es_data_source_samsung.h
Go to the documentation of this file.
1 // Copyright (c) 2016 Samsung Electronics. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef PPAPI_CPP_SAMSUNG_ES_DATA_SOURCE_SAMSUNG_H_
6 #define PPAPI_CPP_SAMSUNG_ES_DATA_SOURCE_SAMSUNG_H_
7 
8 #include <string>
9 
10 #include "ppapi/c/samsung/ppb_media_data_source_samsung.h"
12 #include "ppapi/cpp/resource.h"
14 
20 namespace pp {
21 
22 class ElementaryStreamListener_Samsung;
23 class InstanceHandle;
24 
36  public:
38  ElementaryStream_Samsung& operator=(const ElementaryStream_Samsung& other);
39 
40  virtual ~ElementaryStream_Samsung();
41 
43  virtual PP_ElementaryStream_Type_Samsung GetStreamType() const = 0;
44 
60  int32_t InitializeDone(
61  const CompletionCallback& callback);
62 
78  int32_t InitializeDone(PP_StreamInitializationMode mode,
79  const CompletionCallback& callback);
80 
96  int32_t AppendPacket(
97  const PP_ESPacket& packet,
98  const CompletionCallback& callback);
99 
117  int32_t AppendEncryptedPacket(
118  const PP_ESPacket& packet,
119  const PP_ESPacketEncryptionInfo& encryption_info,
120  const CompletionCallback& callback);
121 
151  int32_t AppendTrustZonePacket(const PP_ESPacket& packet,
152  const PP_TrustZoneReference& handle,
153  const CompletionCallback& callback);
154 
165  int32_t Flush(
166  const CompletionCallback& callback);
167 
181  int32_t SetDRMInitData(
182  uint32_t type_size,
183  const void* type,
184  uint32_t init_data_size,
185  const void* init_data,
186  const CompletionCallback& callback);
187 
188 
205  int32_t SetDRMInitData(
206  const std::string& type,
207  uint32_t init_data_size,
208  const void* init_data,
209  const CompletionCallback& callback);
210 
211  protected:
213  explicit ElementaryStream_Samsung(PP_Resource resource);
214  explicit ElementaryStream_Samsung(const Resource& resource);
215  explicit ElementaryStream_Samsung(PassRef, PP_Resource resource);
216 };
217 
226  public:
228  explicit AudioElementaryStream_Samsung(PP_Resource resource);
229  explicit AudioElementaryStream_Samsung(PassRef, PP_Resource resource);
232  const AudioElementaryStream_Samsung& other);
233 
235 
238  virtual PP_ElementaryStream_Type_Samsung GetStreamType() const;
239 
241  PP_AudioCodec_Type_Samsung GetAudioCodecType() const;
242 
247  void SetAudioCodecType(PP_AudioCodec_Type_Samsung audio_codec);
248 
254  PP_AudioCodec_Profile_Samsung GetAudioCodecProfile() const;
255 
257  void SetAudioCodecProfile(PP_AudioCodec_Profile_Samsung profile);
258 
264  PP_SampleFormat_Samsung GetSampleFormat() const;
265 
267  void SetSampleFormat(PP_SampleFormat_Samsung sample_format);
268 
270  PP_ChannelLayout_Samsung GetChannelLayout() const;
271 
273  void SetChannelLayout(PP_ChannelLayout_Samsung channel_layout);
274 
277  int32_t GetBitsPerChannel() const;
278 
284  void SetBitsPerChannel(int32_t bits_per_channel);
285 
287  int32_t GetSamplesPerSecond() const;
288 
290  void SetSamplesPerSecond(int32_t samples_per_second);
291 
298  void SetCodecExtraData(
299  uint32_t extra_data_size,
300  const void* extra_data);
301 };
302 
311  public:
313  explicit VideoElementaryStream_Samsung(PP_Resource resource);
314  explicit VideoElementaryStream_Samsung(PassRef, PP_Resource resource);
317  const VideoElementaryStream_Samsung& other);
318 
320 
323  virtual PP_ElementaryStream_Type_Samsung GetStreamType() const;
324 
326  PP_VideoCodec_Type_Samsung GetVideoCodecType() const;
327 
332  void SetVideoCodecType(PP_VideoCodec_Type_Samsung video_codec);
333 
335  PP_VideoCodec_Profile_Samsung GetVideoCodecProfile() const;
336 
342  void SetVideoCodecProfile(PP_VideoCodec_Profile_Samsung video_codec);
343 
345  PP_VideoFrame_Format_Samsung GetVideoFrameFormat() const;
346 
352  void SetVideoFrameFormat(PP_VideoFrame_Format_Samsung frame_format);
353 
355  PP_Size GetVideoFrameSize() const;
356 
358  void SetVideoFrameSize(const PP_Size& size);
359 
365  void GetFrameRate(uint32_t* numerator, uint32_t* denominator) const;
366 
371  void SetFrameRate(uint32_t numerator, uint32_t denominator);
372 
379  void SetCodecExtraData(
380  uint32_t extra_data_size,
381  const void* extra_data);
382 };
383 
412  public:
413  explicit ESDataSource_Samsung(const InstanceHandle& instance);
414 
416 
417  explicit ESDataSource_Samsung(PP_Resource resource);
418  ESDataSource_Samsung(PassRef, PP_Resource resource);
419 
420  ESDataSource_Samsung& operator=(const ESDataSource_Samsung& other);
421 
422  virtual ~ESDataSource_Samsung();
423 
440  template<typename T>
441  int32_t AddStream(const CompletionCallbackWithOutput<T>& callback,
442  ElementaryStreamListener_Samsung* listener = NULL);
443 
452  int32_t SetDuration(
453  PP_TimeDelta duration,
454  const CompletionCallback& callback);
455 
464  int32_t SetEndOfStream(
465  const CompletionCallback& callback);
466 
467  private:
482  int32_t AddStream(
483  PP_ElementaryStream_Type_Samsung stream_type,
484  PP_Resource* stream,
486  const CompletionCallback& callback);
487 };
488 
493 template <typename T>
495  static const PP_ElementaryStream_Type_Samsung kType =
496  PP_ELEMENTARYSTREAM_TYPE_SAMSUNG_UNKNOWN;
497 };
498 
499 template <>
501  static const PP_ElementaryStream_Type_Samsung kType =
502  PP_ELEMENTARYSTREAM_TYPE_SAMSUNG_VIDEO;
503 };
504 
505 template <>
507  static const PP_ElementaryStream_Type_Samsung kType =
508  PP_ELEMENTARYSTREAM_TYPE_SAMSUNG_AUDIO;
509 };
510 
511 #if __cplusplus >= 201103L
512 #define PP_MEDIA_PLAYER_SAMSUNG_STATIC_ASSERT(expr, msg) \
513  static_assert(expr, msg)
514 #else
515 #if __GNUC__ >= 4
516 #define UNUSED_TYPEDEF __attribute__((__unused__))
517 #else
518 #define UNUSED_TYPEDEF
519 #endif
520 #define PP_MEDIA_PLAYER_SAMSUNG_STATIC_ASSERT(expr, msg) \
521  do { \
522  typedef int static_assert_check[(expr) ? 1 : -1] UNUSED_TYPEDEF; \
523  } while (0)
524 #endif
525 
526 template<typename T>
528  const CompletionCallbackWithOutput<T>& callback,
530  typedef ElementaryStreamTraits_Samsung<T> Traits;
531  PP_MEDIA_PLAYER_SAMSUNG_STATIC_ASSERT(
532  Traits::kType != PP_ELEMENTARYSTREAM_TYPE_SAMSUNG_UNKNOWN,
533  "Bad stream type!");
534  return AddStream(Traits::kType, callback.output(), listener, callback);
535 }
536 
537 } // namespace pp
538 
539 #endif // PPAPI_CPP_SAMSUNG_ES_DATA_SOURCE_SAMSUNG_H_
Definition: es_data_source_samsung.h:494
Definition: media_data_source_samsung.h:22
int32_t AppendPacket(const PP_ESPacket &packet, const CompletionCallback &callback)
PP_VideoCodec_Type_Samsung GetVideoCodecType() const
Retrieves a currently set video codec type.
Definition: es_data_source_samsung.h:411
Definition: completion_callback.h:189
virtual PP_ElementaryStream_Type_Samsung GetStreamType() const =0
Retrieves stream type represented by this resource.
void SetBitsPerChannel(int32_t bits_per_channel)
int32_t AppendTrustZonePacket(const PP_ESPacket &packet, const PP_TrustZoneReference &handle, const CompletionCallback &callback)
int32_t GetSamplesPerSecond() const
Retrieves a currently set sample rate.
int32_t SetDRMInitData(uint32_t type_size, const void *type, uint32_t init_data_size, const void *init_data, const CompletionCallback &callback)
int32_t AppendEncryptedPacket(const PP_ESPacket &packet, const PP_ESPacketEncryptionInfo &encryption_info, const CompletionCallback &callback)
int32_t SetDuration(PP_TimeDelta duration, const CompletionCallback &callback)
virtual PP_ElementaryStream_Type_Samsung GetStreamType() const
void SetVideoCodecType(PP_VideoCodec_Type_Samsung video_codec)
Listener for receiving elementary stream related events.
Definition: elementary_stream_listener_samsung.h:16
Definition: completion_callback.h:26
void SetAudioCodecProfile(PP_AudioCodec_Profile_Samsung profile)
Retrieves a currently set audio sample format.
PP_VideoCodec_Profile_Samsung GetVideoCodecProfile() const
Retrieves a currently set video codec type.
Definition: es_data_source_samsung.h:35
void SetChannelLayout(PP_ChannelLayout_Samsung channel_layout)
Sets a new audio channel layout.
void SetSamplesPerSecond(int32_t samples_per_second)
Sets how many audio samples were recorded per second (sample rate).
void SetSampleFormat(PP_SampleFormat_Samsung sample_format)
Retrieves a currently set audio channel layout.
Definition: instance_handle.h:44
void SetVideoFrameSize(const PP_Size &size)
Sets new video frame size in pixels.
PassRef
Definition: pass_ref.h:17
void SetFrameRate(uint32_t numerator, uint32_t denominator)
void SetVideoCodecProfile(PP_VideoCodec_Profile_Samsung video_codec)
PP_AudioCodec_Type_Samsung GetAudioCodecType() const
Retrieves a currently set audio codec type.
void SetCodecExtraData(uint32_t extra_data_size, const void *extra_data)
void GetFrameRate(uint32_t *numerator, uint32_t *denominator) const
PP_SampleFormat_Samsung GetSampleFormat() const
PP_Size GetVideoFrameSize() const
Retrieves current video frame size in pixels.
void SetVideoFrameFormat(PP_VideoFrame_Format_Samsung frame_format)
Definition: es_data_source_samsung.h:310
void SetAudioCodecType(PP_AudioCodec_Type_Samsung audio_codec)
int32_t SetEndOfStream(const CompletionCallback &callback)
PP_VideoFrame_Format_Samsung GetVideoFrameFormat() const
Retrieves a currently set video codec profile.
int32_t AddStream(const CompletionCallbackWithOutput< T > &callback, ElementaryStreamListener_Samsung *listener=NULL)
Definition: es_data_source_samsung.h:527
void SetCodecExtraData(uint32_t extra_data_size, const void *extra_data)
int32_t InitializeDone(const CompletionCallback &callback)
int32_t Flush(const CompletionCallback &callback)
virtual PP_ElementaryStream_Type_Samsung GetStreamType() const
A reference counted module resource.
Definition: resource.h:20
PP_ChannelLayout_Samsung GetChannelLayout() const
Retrieves a currently set audio channel layout.
PP_AudioCodec_Profile_Samsung GetAudioCodecProfile() const
Definition: es_data_source_samsung.h:225