Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 3, 2006, 7:47:05 PM (19 years ago)
Author:
hdavid
Message:

branches\avi_play

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/avi_play/src/lib/graphics/importer/media_container.cc

    r6382 r6401  
    4040
    4141  if (filename != NULL)
    42     this->loadMedia(filename);
     42  {
     43    if(!this->loadMedia(filename))
     44      PRINTF(1)("MediaContainer::loadMedia() failed for %s\n", filename);
     45  }
    4346}
    4447
     
    7477}
    7578
    76 void MediaContainer::loadMedia(const char* filename)
     79bool MediaContainer::loadMedia(const char* filename)
    7780{
    7881  // register all formats and codecs
     
    8184  // Open video file
    8285  if (av_open_input_file(&format_context, filename, NULL, 0, NULL) !=0 )
     86  {
    8387    PRINTF(1)("Could not open %s\n", filename);
     88    return false;
     89  }
    8490
    8591  // Retrieve stream information
    8692  if (av_find_stream_info(format_context) < 0)
     93  {
    8794    PRINTF(1)("Could not find stream information in %s\n", filename);
     95    return false;
     96  }
    8897
    8998  // Find the first video stream and take it
     
    91100 
    92101  if(video_stream == -1)
     102  {
    93103    PRINTF(1)("Could not find a video stream in %s\n", filename);
     104    return false;
     105  }
    94106
    95107  // Get a pointer to the codec context for the video stream
     
    101113  codec = avcodec_find_decoder(codec_context->codec_id);
    102114  if (codec == NULL)
     115  {
    103116    PRINTF(1)("Could not find codec\n");
     117    return false;
     118  }
    104119
    105120  // Open codec
    106121  if (avcodec_open(codec_context, codec) < 0)
     122  {
    107123    PRINTF(1)("Could not open codec\n");
     124    return false;
     125  }
    108126
    109127  // Allocate video frame
     
    123141  // Calculate fps
    124142  fps = av_q2d(format_context->streams[video_stream]->r_frame_rate);
     143  // NOTE: fix this fps problem!!
     144  if(fps < 0 || fps > 1000)
     145    fps = 30;
    125146
    126147  // read the frames and save them in a sequence as textures
    127148  this->loadFrames();
     149
     150  return true;
    128151}
    129152
Note: See TracChangeset for help on using the changeset viewer.