OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 5 #ifndef MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
6 #define MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 6 #define MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
7 | 7 |
8 // Used for FFmpeg error codes. | 8 // Used for FFmpeg error codes. |
9 #include <cerrno> | 9 #include <cerrno> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/singleton.h" | 12 #include "base/singleton.h" |
13 | 13 |
14 // Include FFmpeg header files. | 14 // Include FFmpeg header files. |
15 extern "C" { | 15 extern "C" { |
16 // Temporarily disable possible loss of data warning. | 16 // Temporarily disable possible loss of data warning. |
17 // TODO(scherkus): fix and upstream the compiler warnings. | 17 // TODO(scherkus): fix and upstream the compiler warnings. |
18 MSVC_PUSH_DISABLE_WARNING(4244); | 18 MSVC_PUSH_DISABLE_WARNING(4244); |
19 #include <libavcodec/avcodec.h> | 19 #include <libavcodec/avcodec.h> |
20 #include <libavformat/avformat.h> | 20 #include <libavformat/avformat.h> |
21 #include <libavutil/avutil.h> | 21 #include <libavutil/avutil.h> |
22 #include <libavutil/log.h> | 22 #include <libavutil/log.h> |
23 MSVC_POP_WARNING(); | 23 MSVC_POP_WARNING(); |
24 } // extern "C" | 24 } // extern "C" |
25 | 25 |
26 namespace media { | 26 namespace media { |
27 | 27 |
28 // Wraps FFmpeg's av_free() in a class that can be passed as a template argument | 28 // Wraps FFmpeg's av_free() in a class that can be passed as a template argument |
29 // to scoped_ptr_malloc. | 29 // to scoped_ptr_malloc. |
30 class ScopedPtrAVFree { | 30 inline void ScopedPtrAVFree(void* x) { |
31 public: | 31 av_free(x); |
32 inline void operator()(void* x) const { | 32 } |
33 av_free(x); | |
34 } | |
35 }; | |
36 | 33 |
37 // This assumes that the AVPacket being captured was allocated outside of | 34 // This assumes that the AVPacket being captured was allocated outside of |
38 // FFmpeg via the new operator. Do not use this with AVPacket instances that | 35 // FFmpeg via the new operator. Do not use this with AVPacket instances that |
39 // are allocated via malloc() or av_malloc(). | 36 // are allocated via malloc() or av_malloc(). |
40 class ScopedPtrAVFreePacket { | 37 inline void ScopedPtrAVFreePacket(AVPacket* packet) { |
41 public: | 38 av_free_packet(packet); |
42 inline void operator()(void* x) const { | 39 delete packet; |
43 AVPacket* packet = static_cast<AVPacket*>(x); | 40 } |
44 av_free_packet(packet); | |
45 delete packet; | |
46 } | |
47 }; | |
48 | |
49 | 41 |
50 // FFmpeg MIME types. | 42 // FFmpeg MIME types. |
51 namespace mime_type { | 43 namespace mime_type { |
52 | 44 |
53 extern const char kFFmpegAudio[]; | 45 extern const char kFFmpegAudio[]; |
54 extern const char kFFmpegVideo[]; | 46 extern const char kFFmpegVideo[]; |
55 | 47 |
56 } // namespace mime_type | 48 } // namespace mime_type |
57 | 49 |
58 } // namespace media | 50 } // namespace media |
59 | 51 |
60 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 52 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
OLD | NEW |