Advertisement
Guest User

Untitled

a guest
Feb 4th, 2014
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1.  
  2. int main(int argc, char *argv[])
  3. {
  4.  
  5. int flags;
  6. flags = SDL_INIT_VIDEO | SDL_INIT_TIMER;
  7.  
  8. if (SDL_Init (flags)) {
  9. LOGD ("Could not intialize Video for SDL: %s \n", SDL_GetError());
  10. }
  11. else
  12. LOGD (" SUCCESS: SDL_Init ");
  13.  
  14. // ffmpeg Register all services..
  15. ffmpeg_register_all ();
  16.  
  17.  
  18. pFrame = avcodec_alloc_frame ();
  19. context = avformat_alloc_context();
  20.  
  21. err = avformat_open_input (&context, "rtsp:ip:port", NULL, NULL);
  22. if ( err < 0) {
  23. __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "Unable to open rtsp... ");
  24.  
  25. return -1;
  26. }
  27.  
  28. for (i = 0; i < context->nb_streams; i++)
  29. {
  30. // Find the Decoder.
  31. codec = avcodec_find_decoder(context->streams[i]->codec->codec_id);
  32. if (codec->type == AVMEDIA_TYPE_VIDEO ) {
  33. __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "Found Video Streaming.. ");
  34. videoStreamIndex = i;
  35.  
  36. }
  37. }
  38.  
  39. // Play RTSP
  40. av_read_play(context);
  41.  
  42. // Get Codec Context.
  43. pCodecCtx = context->streams[videoStreamIndex]->codec;
  44. if ( pCodecCtx == NULL )
  45. __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "CodecCtx is NULL>>> ");
  46. else
  47. __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "CodecCtx is <<<OK>>> ");
  48.  
  49.  
  50. //Find the Decoder.
  51. pCodec = avcodec_find_decoder (pCodecCtx->codec_id);
  52. avcodec_open2 (pCodecCtx, pCodec, NULL);
  53.  
  54.  
  55. int w = pCodecCtx->width; // Why me getting 0 ?
  56. int h = pCodecCtx->height;
  57.  
  58. window = SDL_CreateWindow ("Test ffmpeg",SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, SDL_WINDOW_SHOWN|SDL_WINDOW_ALLOW_HIGHDPI);
  59. // What this HIGHDPI Means ??
  60.  
  61. if ( window != NULL )
  62. {
  63. LOGD (" WINDOW CREATED.. , create Renderer ..");
  64. renderer = SDL_CreateRenderer (window, -1, 0);
  65. }
  66. else
  67. {
  68. LOGD (" Invalid SDL Window ");
  69. }
  70. __android_log_print(ANDROID_LOG_DEBUG, "ffmpegguard", "Width and Height of PCodeccCtx.. %d .. %d " , w, h);
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement