OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_PACKET_H_ | 5 #ifndef SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_PACKET_H_ |
6 #define SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_PACKET_H_ | 6 #define SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_PACKET_H_ |
7 | 7 |
8 extern "C" { | 8 extern "C" { |
9 #include "third_party/ffmpeg/libavcodec/avcodec.h" | 9 #include "third_party/ffmpeg/libavcodec/avcodec.h" |
10 #include "third_party/ffmpeg/libavformat/avformat.h" | 10 #include "third_party/ffmpeg/libavformat/avformat.h" |
11 } | 11 } |
12 | 12 |
13 namespace mojo { | 13 namespace mojo { |
14 namespace media { | 14 namespace media { |
15 namespace ffmpeg { | 15 namespace ffmpeg { |
16 | 16 |
17 struct AVPacketDeleter { | 17 struct AVPacketDeleter { |
18 inline void operator()(AVPacket* ptr) const { | 18 inline void operator()(AVPacket* ptr) const { av_free_packet(ptr); } |
19 av_free_packet(ptr); | |
20 } | |
21 }; | 19 }; |
22 | 20 |
23 using AvPacketPtr = std::unique_ptr<AVPacket, AVPacketDeleter>; | 21 using AvPacketPtr = std::unique_ptr<AVPacket, AVPacketDeleter>; |
24 | 22 |
25 struct AvPacket{ | 23 struct AvPacket { |
26 static AvPacketPtr Create() { | 24 static AvPacketPtr Create() { |
27 AVPacket* av_packet = new AVPacket(); | 25 AVPacket* av_packet = new AVPacket(); |
28 av_init_packet(av_packet); | 26 av_init_packet(av_packet); |
29 return AvPacketPtr(av_packet); | 27 return AvPacketPtr(av_packet); |
30 } | 28 } |
31 }; | 29 }; |
32 | 30 |
33 } // namespace ffmpeg | 31 } // namespace ffmpeg |
34 } // namespace media | 32 } // namespace media |
35 } // namespace mojo | 33 } // namespace mojo |
36 | 34 |
37 #endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_PACKET_H_ | 35 #endif // SERVICES_MEDIA_FRAMEWORK_FFMPEG_AV_PACKET_H_ |
OLD | NEW |