blob: 7f476582560d8715bea8011c6010361845934fa0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cast/standalone_sender/ffmpeg_glue.h"
#include <libavcodec/version.h>
#include "util/osp_logging.h"
namespace openscreen {
namespace cast {
namespace internal {
AVFormatContext* CreateAVFormatContextForFile(const char* path) {
AVFormatContext* format_context = nullptr;
#if LIBAVCODEC_VERSION_MAJOR < 59
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
av_register_all();
#pragma GCC diagnostic pop
#endif // LIBAVCODEC_VERSION_MAJOR < 59
int result = avformat_open_input(&format_context, path, nullptr, nullptr);
if (result < 0) {
OSP_LOG_ERROR << "Cannot open " << path << ": " << av_err2str(result);
return nullptr;
}
result = avformat_find_stream_info(format_context, nullptr);
if (result < 0) {
avformat_close_input(&format_context);
OSP_LOG_ERROR << "Cannot find stream info in " << path << ": "
<< av_err2str(result);
return nullptr;
}
return format_context;
}
} // namespace internal
} // namespace cast
} // namespace openscreen
|