Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/avi_play/src/lib/graphics/importer/media_container.cc @ 6049

Last change on this file since 6049 was 6049, checked in by hdavid, 18 years ago

branches/avi_play: added new libs to configure.ac, it compiles know on ubuntu :)

File size: 3.3 KB
RevLine 
[5937]1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11### File Specific:
12   main-programmer: David Hasenfratz, Stephan Lienhard
13   co-programmer:
14*/
15
16
17
18/* this is for debug output. It just says, that all calls to PRINT() belong to the DEBUG_MODULE_MEDIA module
19   For more information refere to https://www.orxonox.net/cgi-bin/trac.cgi/wiki/DebugOutput
20*/
21#define DEBUG_MODULE_MEDIA
22
23
24/* include your own header */
25#include "media_container.h"
26
27/* header for debug output */
28#include "debug.h"
29
30
31/**
32 * Default constructor
33 */
[5939]34MediaContainer::MediaContainer(const char* filename)
[5937]35{
[5975]36  /* set the class id for the base object */
37  this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
38
[5962]39  /* register all formats and codecs */
40  av_register_all();
[5937]41
[6013]42  current_frame = 0;
43  num_frames = 0;
[6003]44
[5975]45  if (filename != NULL)
[5962]46    this->loadMedia(filename);
47
[5937]48}
49
50/**
51 * Default destructor
52 */
53MediaContainer::~MediaContainer()
54{
55
[6013]56  /* Free the frame */
[6003]57  av_free(frame);
58
59  /* Close the codec */
60  avcodec_close(codec_context);
61
62  /* Close the video file */
63  av_close_input_file(format_context);
64
[5937]65}
66
[6003]67/*GLuint MediaContainer::getFrame(int frame_number)
[5937]68{
69
70}
71
72GLuint MediaContainer::getNextFrame()
73{
74
[6003]75}*/
76
77SDL_Surface* MediaContainer::getFrame(int frame_number)
78{
[6013]79  SDL_Surface* frame;
[6003]80
[6013]81
82  return frame;
[5937]83}
84
[6003]85SDL_Surface* MediaContainer::getNextFrame()
86{
[6013]87  current_frame++;
88  return this->getFrame(current_frame);
[6003]89}
90
[5975]91void MediaContainer::loadMedia(const char* filename)
[5937]92{
[5975]93  /* Open video file */
94  if (av_open_input_file(&format_context, filename, NULL, 0, NULL) !=0 )
95    PRINTF(1)("Could not open %s\n", filename);
[5937]96
[6013]97  /* Retrieve stream information */
[6003]98  if (av_find_stream_info(format_context) < 0)
[6013]99    PRINTF(1)("Could not find stream information in %s\n", filename); 
[6003]100
101  // Dump information about file onto standard error
102  //dump_format(pFormatCtx, 0, argv[1], false);
103
104  /* Find the first video stream and take it */
105  video_stream = -1;
106  for(int i = 0; i < format_context->nb_streams; i++)
[6013]107  {
108    // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis)
109    // if(format_context->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO)             
110    if(format_context->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO)
[6003]111    {
[6013]112      video_stream = i;
[6003]113      break;
114    }
[6013]115  }
[6003]116 
[6013]117  if(video_stream == -1)
118    PRINTF(1)("Could not find a video stream in %s\n", filename);
[6003]119
[6013]120  /* Get a pointer to the codec context for the video stream */
121  // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis)
122  // codec_context = &format_context->streams[video_stream]->codec;
[6003]123  codec_context = format_context->streams[video_stream]->codec;
124
[6013]125  /* Find the decoder for the video stream */
[6003]126  codec = avcodec_find_decoder(codec_context->codec_id);
127  if (codec == NULL)
[6013]128    PRINTF(1)("Could not find codec\n");
[6003]129
[6013]130  /* Open codec */
[6003]131  if (avcodec_open(codec_context, codec) < 0)
[6013]132    PRINTF(1)("Could not open codec\n");       
[6003]133
[5937]134}
135
136int MediaContainer::getHeight()
137{
138
139}
140
141int MediaContainer::getWidth()
142{
143
144}
145
146int MediaContainer::getFrameRate()
147{
148
149}
150
151void MediaContainer::getStream(/* stream */)
152{
153
154}
Note: See TracBrowser for help on using the repository browser.