34#include <vdr/interface.h>
35#include <vdr/player.h>
36#include <vdr/plugin.h>
37#include <vdr/videodir.h>
46#include <libavcodec/avcodec.h>
47#include <libavformat/avformat.h>
60:cPlayer (pmAudioVideo)
63 m_pSource = (
char *) malloc(1 + strlen(url));
143 LOGERROR(
"mediaplayer: %s: open PL %s failed", __FUNCTION__, Playlist);
150 if (s.size() && s.compare(0, 1,
"#")) {
155 entry->
File = entry->
Path.substr(entry->
Path.find_last_of(
"/") +1, string::npos);
157 string SubString = entry->
Path.substr(0, entry->
Path.find_last_of(
"/"));
158 entry->
SubFolder = SubString.substr(SubString.find_last_of(
"/") +1, string::npos);
160 string FolderString = entry->
Path.substr(0, SubString.find_last_of(
"/"));
161 entry->
Folder = FolderString.substr(FolderString.find_last_of(
"/") +1, string::npos);
181 for(
int i = 0; i < index ; i++) {
191#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(59,0,100)
192 AVCodec *video_codec;
194 const AVCodec *video_codec;
197 int audio_stream_index = 0;
198 int video_stream_index;
199 int jump_stream_index = 0;
205 AVFormatContext *format = avformat_alloc_context();
206 if (avformat_open_input(&format, url, NULL, NULL) != 0) {
207 LOGERROR(
"mediaplayer: %s: Could not open file '%s'", __FUNCTION__, url);
211 av_dump_format(format, -1, url, 0);
213 if (avformat_find_stream_info(format, NULL) < 0) {
214 LOGERROR(
"mediaplayer: %s: Could not retrieve stream info from file '%s'", __FUNCTION__, url);
218 for (
unsigned int i = 0; i < format->nb_streams; i++) {
219 if (format->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
221 format->streams[i]->codecpar, format->streams[i]->time_base);
222 audio_stream_index = jump_stream_index = i;
227 video_stream_index = av_find_best_stream(format, AVMEDIA_TYPE_VIDEO,
228 -1, -1, &video_codec, 0);
230 if (video_stream_index < 0) {
231 LOGDEBUG2(
L_MEDIA,
"mediaplayer: %s: stream does not seem to contain video", __FUNCTION__);
234 format->streams[video_stream_index]->codecpar,
235 format->streams[video_stream_index]->time_base);
236 jump_stream_index = video_stream_index;
239 Duration = format->duration / AV_TIME_BASE;
240 start_time = format->start_time / AV_TIME_BASE;
242 AVPacket *packet =
nullptr;
245 packet = av_packet_alloc();
247 LOGFATAL(
"mediaplayer: %s: out of memory", __FUNCTION__);
251 err = av_read_frame(format, packet);
253 LOGDEBUG2(
L_MEDIA,
"mediaplayer: %s: av_read_frame error: %s", __FUNCTION__,
256 av_packet_free(&packet);
261 if (audio_stream_index == packet->stream_index) {
263 usleep(packet->duration * AV_TIME_BASE *
264 av_q2d(format->streams[audio_stream_index]->time_base));
267 av_packet_free(&packet);
270 }
else if (video_stream_index == packet->stream_index) {
272 usleep(packet->duration * AV_TIME_BASE *
273 av_q2d(format->streams[video_stream_index]->time_base));
278 av_packet_free(&packet);
285 if (
Jump && format->pb->seekable) {
286 av_seek_frame(format, format->streams[jump_stream_index]->index,
287 packet->pts + (int64_t)(
Jump /
288 av_q2d(format->streams[jump_stream_index]->time_base)), 0);
293 av_packet_free(&packet);
305 av_packet_free(&packet);
310 avformat_close_input(&format);
311 avformat_free_context(format);
366 m_pOsd = Skins.Current()->DisplayReplay(
false);
Audio and alsa module header file.
int64_t GetHardwareOutputPtsMs(void)
Get the hardware output PTS in milliseconds.
virtual eOSState ProcessKey(eKeys)
Handle a key event.
cSoftHdControl(const char *, cSoftHdDevice *)
Player control constructor.
static cSoftHdControl * Control()
cSoftHdDevice * m_pDevice
cSkinDisplayReplay * m_pOsd
static cSoftHdPlayer * m_pPlayer
static cSoftHdControl * m_pControl
virtual ~cSoftHdControl()
Player control destructor.
int PlayAudioPkts(AVPacket *)
Play an audio packet.
virtual void Clear(void)
Clears all video and audio data from the device.
void SetAudioCodec(enum AVCodecID, AVCodecParameters *, AVRational)
Open an audio codec.
virtual void Play(void)
Sets the device into play mode (after a previous trick mode, or pause)
int PlayVideoPkts(AVPacket *)
Play a video packet.
virtual void Freeze(void)
Puts the device into "freeze frame" mode.
void SetVideoCodec(enum AVCodecID, AVCodecParameters *, AVRational)
Open a video codec.
cSoftHdAudio * Audio(void)
const char * GetTitle(void)
virtual void Action(void)
void Player(const char *)
void ReadPL(const char *)
struct PLEntry * FirstEntry
virtual void Activate(bool On)
struct PLEntry * CurrentEntry
cSoftHdDevice * m_pDevice
cSoftHdPlayer(const char *, cSoftHdDevice *)
Logger class header file.
#define LOGFATAL
Logger macros.
Misc function header file.
Device class header file.
struct PLEntry * NextEntry
Videostream class header file.