Pepper_31_C++_interfaces
stream_parser_samsung.h
Go to the documentation of this file.
1 // Copyright 2013 The Chromium Authors. 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_STREAM_PARSER_SAMSUNG_H_
6 #define PPAPI_CPP_SAMSUNG_STREAM_PARSER_SAMSUNG_H_
7 
8 #include "ppapi/cpp/instance.h"
9 #include "ppapi/cpp/var.h"
10 #include "ppapi/cpp/dev/buffer_dev.h"
11 #include "ppapi/c/samsung/pp_media_common_samsung.h"
12 #include "ppapi/c/samsung/pp_stream_parser_samsung.h"
13 
14 namespace pp {
15 
16 class InstanceHandle;
17 
18 /// Interface allowing NaCl applicaton to implement its own stream demuxer
20  public:
21 
22  /// Creates StreamParser_Samsung associated with given |instance|
23  explicit StreamParser_Samsung(Instance* instance);
24 
25  /// Destructor
26  virtual ~StreamParser_Samsung() {}
27 
28  // PPB_StreamParser_Samsung API
29 
30  /// Used for registering stream parser in Browser. |type| is a MIME type
31  /// of stream, to witch parser be registered.
32  bool RegisterParser(const char* type);
33 
34  /// Indicates completion of parser initialization. |stream_id| it's a id
35  /// of stream, that Browser request to parse, if Borwser request parsing more
36  /// that one stream of that type, it's allows to recognize that stream.
37  /// On success, |result| is set to PP_OK, or PP_FALSE if an error occurred.
38  /// If initialization is success, the |duration| contains stream duration
39  /// (in microseconds).
40  bool Init(int32_t stream_id, bool result, PP_MicrosecondsDelta duration);
41 
42  /// Indicates when new audio configuration have been parsed,
43  /// |config| it's a configuration struct
44  bool NewAudioConfig(int32_t stream_id, const PP_SP_AudioDecoderConfig&);
45 
46  /// Indicates when new video configuration have been parsed,
47  /// |config| it's a configuration struct
48  bool NewVideoConfig(int32_t stream_id, const PP_SP_VideoDecoderConfig&);
49 
50  /// New stream buffers have been parsed, |type| indicates type of track it's
51  /// enum defined in pp_stream_parser_samsung.h, |track_id| it's id of track,
52  /// useful if is more that one track of that type
53  bool NewBuffers(int32_t stream_id, PP_StreamType type,
54  int32_t track_id, PP_Resource buffer, uint32_t frames_count,
55  const struct PP_Frames frames[]);
56 
57  /// Signals the beginning od a new media segment, |timestamp| the earliest
58  /// timestamp of all the streams in the segment
59  void NewMediaSegment(int32_t stream_id, PP_MicrosecondsDelta timestamp);
60 
61  /// Signals end of segment for given |stream_id|
62  void EndOfSegment(int32_t stream_id);
63 
64  /// A new potentialy encrypted stream has been parsed. |type| describes type
65  /// of the initialization data |init_data| associated with the stream.
66  bool NeedKey(int32_t stream_id, const Var& type,
67  uint32_t init_data_size, uint8_t* init_data);
68 
69  // PPP_StreamParser_Samsung API
70 
71  /// Initialize the parser. Must be called before any data is passed to Parse().
72  /// |stream_type| describe type of stream to parse (should be one of type,
73  /// passed in PPB RegisterParser). |stream_id| it's a id of stream to parse.
74  virtual bool Init(int32_t stream_id) = 0;
75 
76  /// Called when a seek occurs. This flushes the current parser state and puts
77  /// the parser in a state where it can receive data for the new seek point.
78  virtual void Flush(int32_t stream_id) = 0;
79 
80  /// Called when there is new data to parse. |data| contains stream to parse.
81  ///
82  /// Return PP_OK if the parse succeds
83  virtual bool Parse(int32_t stream_id, Buffer_Dev data) = 0;
84 
85  /// Called when a parser must be "closed". Used for flushes the current parser
86  // state, and configs.
87  virtual void Close(int32_t stream_id) = 0;
88 
89  private:
90  Instance* instance_;
91  PP_Bool registered_;
92 };
93 
94 } // namespace pp
95 
96 #endif // PPAPI_CPP_SAMSUNG_STREAM_PARSER_SAMSUNG_H_
bool NeedKey(int32_t stream_id, const Var &type, uint32_t init_data_size, uint8_t *init_data)
bool Init(int32_t stream_id, bool result, PP_MicrosecondsDelta duration)
bool NewAudioConfig(int32_t stream_id, const PP_SP_AudioDecoderConfig &)
virtual ~StreamParser_Samsung()
Destructor.
Interface allowing NaCl applicaton to implement its own stream demuxer.
bool RegisterParser(const char *type)
bool NewBuffers(int32_t stream_id, PP_StreamType type, int32_t track_id, PP_Resource buffer, uint32_t frames_count, const struct PP_Frames frames[])
void EndOfSegment(int32_t stream_id)
Signals end of segment for given |stream_id|.
virtual void Flush(int32_t stream_id)=0
StreamParser_Samsung(Instance *instance)
Creates StreamParser_Samsung associated with given |instance|.
void NewMediaSegment(int32_t stream_id, PP_MicrosecondsDelta timestamp)
bool NewVideoConfig(int32_t stream_id, const PP_SP_VideoDecoderConfig &)
A generic type used for passing data types between the module and the page.
Definition: var.h:20
virtual void Close(int32_t stream_id)=0
Called when a parser must be "closed". Used for flushes the current parser.
virtual bool Parse(int32_t stream_id, Buffer_Dev data)=0