Advertisement
undeadhip

Untitled

Apr 7th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (kxMovieError) openInput: (NSString *) path
  2. {
  3.     AVFormatContext *formatCtx = NULL;
  4.    
  5.     if (_interruptCallback) {
  6.        
  7.         formatCtx = avformat_alloc_context();
  8.         if (!formatCtx)
  9.             return kxMovieErrorOpenFile;
  10.        
  11.         AVIOInterruptCB cb = {interrupt_callback, (__bridge void *)(self)};
  12.         formatCtx->interrupt_callback = cb;
  13.     }
  14.    
  15.     if (avformat_open_input(&formatCtx, [path cStringUsingEncoding: NSUTF8StringEncoding], NULL, NULL) < 0) {
  16.        
  17.         if (formatCtx)
  18.             avformat_free_context(formatCtx);
  19.         return kxMovieErrorOpenFile;
  20.     }
  21.    
  22.     if (avformat_find_stream_info(formatCtx, NULL) < 0) {
  23.        
  24.         avformat_close_input(&formatCtx);
  25.         return kxMovieErrorStreamInfoNotFound;
  26.     }
  27.  
  28.     av_dump_format(formatCtx, 0, [path.lastPathComponent cStringUsingEncoding: NSUTF8StringEncoding], false);
  29.    
  30.     _formatCtx = formatCtx;
  31.     return kxMovieErrorNone;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement