private final void handleStop() {
   if (DEBUG) Log.v(TAG, "handleStop:");
   synchronized (mVideoTask) {
     internal_stop_video();
     mVideoTrackIndex = -1;
   }
   if (mVideoMediaCodec != null) {
     mVideoMediaCodec.stop();
     mVideoMediaCodec.release();
     mVideoMediaCodec = null;
   }
   if (mVideoMediaExtractor != null) {
     mVideoMediaExtractor.release();
     mVideoMediaExtractor = null;
   }
   mVideoBufferInfo = null;
   mVideoInputBuffers = mVideoOutputBuffers = null;
   if (mMetadata != null) {
     mMetadata.release();
     mMetadata = null;
   }
   synchronized (mSync) {
     mVideoOutputDone = mVideoInputDone = true;
     mState = STATE_STOP;
   }
   mCallback.onFinished();
 }
Exemplo n.º 2
0
 private static boolean hasCodecsForResourceCombo(
     Context context, int resourceId, int track, String mimePrefix) {
   try {
     AssetFileDescriptor afd = null;
     MediaExtractor ex = null;
     try {
       afd = context.getResources().openRawResourceFd(resourceId);
       ex = new MediaExtractor();
       ex.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
       if (mimePrefix != null) {
         return hasCodecForMediaAndDomain(ex, mimePrefix);
       } else if (track == ALL_AV_TRACKS) {
         return hasCodecsForMedia(ex);
       } else {
         return hasCodecForTrack(ex, track);
       }
     } finally {
       if (ex != null) {
         ex.release();
       }
       if (afd != null) {
         afd.close();
       }
     }
   } catch (IOException e) {
     Log.i(TAG, "could not open resource");
   }
   return false;
 }
Exemplo n.º 3
0
 void teardown() {
   if (decoder != null) {
     decoder.release();
     decoder = null;
   }
   if (surface != null) {
     surface.release();
     surface = null;
   }
   if (extractor != null) {
     extractor.release();
     extractor = null;
   }
 }
 @Override
 public void reset() {
   L.v(TAG, "reset called in state: " + state);
   stayAwake(false);
   lock.lock();
   try {
     continuing = false;
     try {
       if (state != State.PLAYBACK_COMPLETED) {
         while (isDecoding) {
           synchronized (decoderLock) {
             decoderLock.notify();
             decoderLock.wait();
           }
         }
       }
     } catch (InterruptedException e) {
       L.e(TAG, "Interrupted in reset while waiting for decoder thread to stop.", e);
     }
     if (codec != null) {
       codec.release();
       L.d(TAG, "releasing codec");
       codec = null;
     }
     if (extractor != null) {
       extractor.release();
       extractor = null;
     }
     if (track != null) {
       track.release();
       track = null;
     }
     state = State.IDLE;
     L.d(TAG, "State changed to: " + state);
   } finally {
     lock.unlock();
   }
 }
Exemplo n.º 5
0
 /** return true iff all audio and video tracks are supported */
 public static boolean hasCodecsForPath(Context context, String path) {
   MediaExtractor ex = null;
   try {
     ex = new MediaExtractor();
     Uri uri = Uri.parse(path);
     String scheme = uri.getScheme();
     if (scheme == null) { // file
       ex.setDataSource(path);
     } else if (scheme.equalsIgnoreCase("file")) {
       ex.setDataSource(uri.getPath());
     } else {
       ex.setDataSource(context, uri, null);
     }
     return hasCodecsForMedia(ex);
   } catch (IOException e) {
     Log.i(TAG, "could not open path " + path);
   } finally {
     if (ex != null) {
       ex.release();
     }
   }
   return false;
 }