Class ShadowMediaMuxer


  • @Implements(value=android.media.MediaMuxer.class,
                minSdk=21)
    public class ShadowMediaMuxer
    extends java.lang.Object
    Implementation of MediaMuxer which directly passes input bytes to the specified file, with no modification.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void __constructor__​(java.lang.String path, int format)
      Opens a FileOutputStream for the given path, and sets muxer state.
      protected static int nativeAddTrack​(long nativeObject, java.lang.String[] keys, java.lang.Object[] values)
      Returns an incremented track id for the associated muxer.
      protected static long nativeSetup​(java.io.FileDescriptor fd, int format)
      Generates and returns an internal id to track the FileOutputStream corresponding to individual MediaMuxer instances.
      protected static void nativeStop​(long nativeObject)
      Closes the FileOutputStream for the associated muxer.
      protected static void nativeWriteSampleData​(long nativeObject, int trackIndex, java.nio.ByteBuffer byteBuf, int offset, int size, long presentationTimeUs, int flags)
      Writes the given data to the FileOutputStream for the associated muxer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShadowMediaMuxer

        public ShadowMediaMuxer()
    • Method Detail

      • __constructor__

        @Implementation
        protected void __constructor__​(java.lang.String path,
                                       int format)
                                throws java.io.IOException
        Opens a FileOutputStream for the given path, and sets muxer state.

        This needs to be shadowed, because the current MediaMuxer constructor opens a RandomAccessFile, passes only the FileDescriptor along, and then closes the file. Since there does not appear to be an easy way to go from FileDescriptor to a writeable stream in Java, this method overrides that behavior to instead open and maintain a FileOutputStream.

        Throws:
        java.io.IOException
      • nativeSetup

        @Implementation
        protected static long nativeSetup​(java.io.FileDescriptor fd,
                                          int format)
                                   throws java.io.IOException
        Generates and returns an internal id to track the FileOutputStream corresponding to individual MediaMuxer instances.
        Throws:
        java.io.IOException
      • nativeAddTrack

        @Implementation
        protected static int nativeAddTrack​(long nativeObject,
                                            java.lang.String[] keys,
                                            java.lang.Object[] values)
        Returns an incremented track id for the associated muxer.
      • nativeWriteSampleData

        @Implementation
        protected static void nativeWriteSampleData​(long nativeObject,
                                                    int trackIndex,
                                                    java.nio.ByteBuffer byteBuf,
                                                    int offset,
                                                    int size,
                                                    long presentationTimeUs,
                                                    int flags)
        Writes the given data to the FileOutputStream for the associated muxer.
      • nativeStop

        @Implementation
        protected static void nativeStop​(long nativeObject)
        Closes the FileOutputStream for the associated muxer.