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
Line 
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 */
34MediaContainer::MediaContainer(const char* filename)
35{
36  /* set the class id for the base object */
37  this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
38
39  /* register all formats and codecs */
40  av_register_all();
41
42  current_frame = 0;
43  num_frames = 0;
44
45  if (filename != NULL)
46    this->loadMedia(filename);
47
48}
49
50/**
51 * Default destructor
52 */
53MediaContainer::~MediaContainer()
54{
55
56  /* Free the frame */
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
65}
66
67/*GLuint MediaContainer::getFrame(int frame_number)
68{
69
70}
71
72GLuint MediaContainer::getNextFrame()
73{
74
75}*/
76
77SDL_Surface* MediaContainer::getFrame(int frame_number)
78{
79  SDL_Surface* frame;
80
81
82  return frame;
83}
84
85SDL_Surface* MediaContainer::getNextFrame()
86{
87  current_frame++;
88  return this->getFrame(current_frame);
89}
90
91void MediaContainer::loadMedia(const char* filename)
92{
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);
96
97  /* Retrieve stream information */
98  if (av_find_stream_info(format_context) < 0)
99    PRINTF(1)("Could not find stream information in %s\n", filename); 
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++)
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)
111    {
112      video_stream = i;
113      break;
114    }
115  }
116 
117  if(video_stream == -1)
118    PRINTF(1)("Could not find a video stream in %s\n", filename);
119
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;
123  codec_context = format_context->streams[video_stream]->codec;
124
125  /* Find the decoder for the video stream */
126  codec = avcodec_find_decoder(codec_context->codec_id);
127  if (codec == NULL)
128    PRINTF(1)("Could not find codec\n");
129
130  /* Open codec */
131  if (avcodec_open(codec_context, codec) < 0)
132    PRINTF(1)("Could not open codec\n");       
133
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.