07584277cb5b13893ca99dc594fc842c02a1a549
[platform/framework/web/crosswalk-tizen.git] /
1 // Copyright 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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_MEDIA_PLAYER_TIZEN_PEPPER_VIDEO_ELEMENTARY_STREAM_PRIVATE_TIZEN_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_MEDIA_PLAYER_TIZEN_PEPPER_VIDEO_ELEMENTARY_STREAM_PRIVATE_TIZEN_H_
7
8 #include <vector>
9
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "content/browser/renderer_host/pepper/media_player/pepper_video_elementary_stream_private.h"
13 #include "content/browser/renderer_host/pepper/media_player/tizen/pepper_elementary_stream_private_tizen.h"
14 #include "content/browser/renderer_host/pepper/media_player/tizen/pepper_player_adapter_base.h"
15
16 namespace content {
17
18 struct PepperTizenVideoStreamTraits {
19   typedef ppapi::VideoCodecConfig CodecConfig;
20   typedef PepperVideoStreamInfo StreamInfo;
21   static constexpr PP_ElementaryStream_Type_Samsung Type =
22       PP_ELEMENTARYSTREAM_TYPE_SAMSUNG_VIDEO;
23   static int32_t SetStreamInfo(PepperPlayerAdapterInterface* player,
24                                const StreamInfo& player_stream_info) {
25     return player->SetVideoStreamInfo(player_stream_info);
26   }
27 };
28
29 class PepperVideoElementaryStreamPrivateTizen
30     : public PepperElementaryStreamPrivateTizen<
31           PepperVideoElementaryStreamPrivate,
32           PepperTizenVideoStreamTraits> {
33  public:
34   static scoped_refptr<PepperVideoElementaryStreamPrivateTizen> Create(
35       PepperESDataSourcePrivate* es_data_source);
36   ~PepperVideoElementaryStreamPrivateTizen() override;
37
38   void InitializeDone(PP_StreamInitializationMode mode,
39                       const ppapi::VideoCodecConfig& config,
40                       const base::Callback<void(int32_t)>& callback) override;
41
42   void AppendPacket(std::unique_ptr<ppapi::ESPacket> packet,
43                     const base::Callback<void(int32_t)>& callback) override;
44
45   void AppendEncryptedPacket(
46       std::unique_ptr<ppapi::EncryptedESPacket> packet,
47       const base::Callback<void(int32_t)>& callback) override;
48
49  private:
50   using BaseClass =
51       PepperElementaryStreamPrivateTizen<PepperVideoElementaryStreamPrivate,
52                                          PepperTizenVideoStreamTraits>;
53
54   explicit PepperVideoElementaryStreamPrivateTizen(
55       PepperESDataSourcePrivate* es_data_source);
56
57   void ExtractCodecExtraData(const ppapi::VideoCodecConfig& config);
58   void ExtractH264ExtraData(const ppapi::VideoCodecConfig& config);
59   void ExtractH265ExtraData(const ppapi::VideoCodecConfig& config);
60
61   std::vector<uint8_t> video_extra_data_;
62 };
63
64 }  // namespace content
65
66 #endif  // CONTENT_BROWSER_RENDERER_HOST_PEPPER_MEDIA_PLAYER_TIZEN_PEPPER_VIDEO_ELEMENTARY_STREAM_PRIVATE_TIZEN_H_