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 // Used with URLProtocol. | 14 // Used with URLProtocol. |
15 typedef int64 offset_t; | 15 typedef int64 offset_t; |
16 | 16 |
17 // Include FFmpeg header files. | 17 // Include FFmpeg header files. |
18 extern "C" { | 18 extern "C" { |
19 // Temporarily disable possible loss of data warning. | 19 // Temporarily disable possible loss of data warning. |
20 // TODO(scherkus): fix and upstream the compiler warnings. | 20 // TODO(scherkus): fix and upstream the compiler warnings. |
21 MSVC_PUSH_DISABLE_WARNING(4244); | 21 MSVC_PUSH_DISABLE_WARNING(4244); |
22 #include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavcodec/avcodec.h" | 22 #include "third_party/ffmpeg/include/libavcodec/avcodec.h" |
23 #include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavformat/avformat.h" | 23 #include "third_party/ffmpeg/include/libavformat/avformat.h" |
24 #include "third_party/ffmpeg/source/patched-ffmpeg-mt/libavutil/log.h" | 24 #include "third_party/ffmpeg/include/libavutil/log.h" |
25 MSVC_POP_WARNING(); | 25 MSVC_POP_WARNING(); |
26 } // extern "C" | 26 } // extern "C" |
27 | 27 |
28 namespace media { | 28 namespace media { |
29 | 29 |
| 30 // FFmpegLock is used to serialize calls to avcodec_open(), avcodec_close(), |
| 31 // and av_find_stream_info() for an entire process because for whatever reason |
| 32 // it does Very Bad Things to other FFmpeg instances. |
| 33 // |
| 34 // TODO(scherkus): track down and upstream a fix to FFmpeg, if possible. |
| 35 class FFmpegLock : public Singleton<FFmpegLock> { |
| 36 public: |
| 37 Lock& lock(); |
| 38 |
| 39 private: |
| 40 // Only allow Singleton to create and delete FFmpegLock. |
| 41 friend struct DefaultSingletonTraits<FFmpegLock>; |
| 42 FFmpegLock(); |
| 43 virtual ~FFmpegLock(); |
| 44 |
| 45 Lock lock_; |
| 46 DISALLOW_COPY_AND_ASSIGN(FFmpegLock); |
| 47 }; |
| 48 |
| 49 |
30 // Wraps FFmpeg's av_free() in a class that can be passed as a template argument | 50 // Wraps FFmpeg's av_free() in a class that can be passed as a template argument |
31 // to scoped_ptr_malloc. | 51 // to scoped_ptr_malloc. |
32 class ScopedPtrAVFree { | 52 class ScopedPtrAVFree { |
33 public: | 53 public: |
34 inline void operator()(void* x) const { | 54 inline void operator()(void* x) const { |
35 av_free(x); | 55 av_free(x); |
36 } | 56 } |
37 }; | 57 }; |
38 | 58 |
39 // This assumes that the AVPacket being captured was allocated outside of | 59 // This assumes that the AVPacket being captured was allocated outside of |
(...skipping 13 matching lines...) Expand all Loading... |
53 namespace mime_type { | 73 namespace mime_type { |
54 | 74 |
55 extern const char kFFmpegAudio[]; | 75 extern const char kFFmpegAudio[]; |
56 extern const char kFFmpegVideo[]; | 76 extern const char kFFmpegVideo[]; |
57 | 77 |
58 } // namespace mime_type | 78 } // namespace mime_type |
59 | 79 |
60 } // namespace media | 80 } // namespace media |
61 | 81 |
62 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ | 82 #endif // MEDIA_FFMPEG_FFMPEG_COMMON_H_ |
OLD | NEW |