3 #ifndef REMOTEAVFORMATCONTEXT_H
4 #define REMOTEAVFORMATCONTEXT_H
17 #include <libavformat/avformat.h>
18 #include <libavformat/avio.h>
19 #include <libavutil/opt.h>
39 LOG(VB_PLAYBACK, LOG_ERR, QString(
"RemoteAVFormatContext::Open: Opening %1").arg(
filename));
70 AVProbeData probe_data;
71 memset(&probe_data, 0,
sizeof(AVProbeData));
72 probe_data.filename =
"stream";
76 const AVInputFormat *fmt = av_probe_input_format(&probe_data, 1);
79 LOG(VB_GENERAL, LOG_ERR, QString(
"RemoteAVFormatContext::Open: Failed to probe file: %1").arg(
filename));
82 LOG(VB_PLAYBACK, LOG_INFO, QString(
"RemoteAVFormatContext::Open: probed file as %1").arg(fmt->name));
88 int ret = avformat_open_input(&
m_inputFC,
"stream", fmt,
nullptr);
91 LOG(VB_GENERAL, LOG_ERR, QString(
"RemoteAVFormatContext::Open: Failed to open input: %1").arg(
filename));
98 AVDictionary *
options =
nullptr;
101 av_dict_set(&
options,
"icy",
"1", 0);
106 LOG(VB_GENERAL, LOG_ERR, QString(
"RemoteAVFormatContext::Open: Failed to open input: %1").arg(
filename));
131 operator AVFormatContext * ()
const {
return m_inputFC; }
136 static int ReadFunc(
void *opaque, uint8_t *buf,
int buf_size)
138 auto *rf =
reinterpret_cast< RemoteFile*
>(opaque);
139 int len = rf->
Read(buf, buf_size);
140 int ret = ((len == 0) && (buf_size > 0)) ? AVERROR_EOF : len;
147 static int64_t
SeekFunc(
void *opaque, int64_t offset,
int whence)
149 auto *rf =
reinterpret_cast< RemoteFile*
>(opaque);
150 if (whence == AVSEEK_SIZE)
153 return rf->Seek(offset, whence);
164 #endif // REMOTEAVFORMATCONTEXT_H