Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 15, 2006, 3:10:45 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the std-branche back, it runs on windows and Linux

svn merge https://svn.orxonox.net/orxonox/branches/std . -r7202:HEAD

File:
1 edited

Legend:

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

    r7193 r7221  
    3434 * Default constructor
    3535 */
    36 MediaContainer::MediaContainer(const char* filename)
     36MediaContainer::MediaContainer(const std::string& filename)
    3737{
    3838  // set the class id for the base object
     
    4141  fps = 0;
    4242  mediaLoaded = false;
    43 
    44   this->loadMedia(filename);
     43  if (!filename.empty())
     44    this->loadMedia(filename);
    4545}
    4646
     
    8484}
    8585
    86 bool MediaContainer::loadMedia(const char* filename)
     86bool MediaContainer::loadMedia(const std::string& filename)
    8787{
    8888  this->unloadMedia();
    8989
    90   if(filename == NULL)
     90  if(filename.empty())
    9191    return false;
    9292  // check whether file exists
    9393  if(!ResourceManager::isInDataDir(filename))
    9494  {
    95     PRINTF(1)("Could not find %s\n", filename);
     95    PRINTF(1)("Could not find %s\n", filename.c_str());
    9696    return false;
    9797  }
     
    101101
    102102  // Open video file
    103   if (av_open_input_file(&format_context, ResourceManager::getFullName(filename), NULL, 0, NULL) !=0 )
    104   {
    105     PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename));
     103  if (av_open_input_file(&format_context, ResourceManager::getFullName(filename).c_str(), NULL, 0, NULL) !=0 )
     104  {
     105    PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename).c_str());
    106106    return false;
    107107  }
     
    110110  if (av_find_stream_info(format_context) < 0)
    111111  {
    112     PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename));
     112    PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename).c_str());
    113113    return false;
    114114  }
     
    116116  // Find the first video stream and take it
    117117  video_stream = av_find_default_stream_index(format_context);
    118  
     118
    119119  if(video_stream == -1)
    120120  {
    121     PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename));
     121    PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename).c_str());
    122122    return false;
    123123  }
     
    202202      // Free the packet that was allocated by av_read_frame
    203203      av_free_packet(&packet);
    204      
     204
    205205      // Did we get a video frame?
    206206      if(frame_finished)
     
    216216          memcpy(&data[i*codec_context->width*3],
    217217                 ((AVPicture*)RGB_frame)->data[0]+i *
    218                  ((AVPicture*)RGB_frame)->linesize[0], 
     218                 ((AVPicture*)RGB_frame)->linesize[0],
    219219                  codec_context->width*sizeof(uint8_t)*3);
    220220
     
    258258  }
    259259  else
    260     return NULL;
    261 }
     260    return 0;
     261}
Note: See TracChangeset for help on using the changeset viewer.