/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: David Hasenfratz, Stephan Lienhard co-programmer: */ /* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_MEDIA module For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput */ #define DEBUG_MODULE_MEDIA /* include your own header */ #include "media_container.h" /* header for debug output */ #include "debug.h" /** * Default constructor */ MediaContainer::MediaContainer(const char* filename) { /* set the class id for the base object */ this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer"); /* register all formats and codecs */ av_register_all(); current_frame = 0; num_frames = 0; if (filename != NULL) this->loadMedia(filename); } /** * Default destructor */ MediaContainer::~MediaContainer() { /* Free the frame */ av_free(frame); /* Close the codec */ avcodec_close(codec_context); /* Close the video file */ av_close_input_file(format_context); } /*GLuint MediaContainer::getFrame(int frame_number) { } GLuint MediaContainer::getNextFrame() { }*/ SDL_Surface* MediaContainer::getFrame(int frame_number) { SDL_Surface* frame; return frame; } SDL_Surface* MediaContainer::getNextFrame() { current_frame++; return this->getFrame(current_frame); } void MediaContainer::loadMedia(const char* filename) { /* Open video file */ if (av_open_input_file(&format_context, filename, NULL, 0, NULL) !=0 ) PRINTF(1)("Could not open %s\n", filename); /* Retrieve stream information */ if (av_find_stream_info(format_context) < 0) PRINTF(1)("Could not find stream information in %s\n", filename); // Dump information about file onto standard error //dump_format(pFormatCtx, 0, argv[1], false); /* Find the first video stream and take it */ video_stream = -1; for(int i = 0; i < format_context->nb_streams; i++) { // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis) // if(format_context->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO) if(format_context->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO) { video_stream = i; break; } } if(video_stream == -1) PRINTF(1)("Could not find a video stream in %s\n", filename); /* Get a pointer to the codec context for the video stream */ // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis) // codec_context = &format_context->streams[video_stream]->codec; codec_context = format_context->streams[video_stream]->codec; /* Find the decoder for the video stream */ codec = avcodec_find_decoder(codec_context->codec_id); if (codec == NULL) PRINTF(1)("Could not find codec\n"); /* Open codec */ if (avcodec_open(codec_context, codec) < 0) PRINTF(1)("Could not open codec\n"); } int MediaContainer::getHeight() { } int MediaContainer::getWidth() { } int MediaContainer::getFrameRate() { } void MediaContainer::getStream(/* stream */) { }