Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6ac859f authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Remove filename based writer constructors

MediaPlayerService can't open files (it needs an already opened
file descriptor), so these were just wasting space.

Change-Id: I323044a6c1814a7bff952ed71b5c7792df2abf03
parent a1ded198
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -23,7 +23,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>

#include <termios.h>
#include <unistd.h>

@@ -637,7 +640,13 @@ static status_t recordScreen(const char* fileName) {
        case FORMAT_MP4: {
            // Configure muxer.  We have to wait for the CSD blob from the encoder
            // before we can start it.
            muxer = new MediaMuxer(fileName, MediaMuxer::OUTPUT_FORMAT_MPEG_4);
            int fd = open(fileName, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
            if (fd < 0) {
                fprintf(stderr, "ERROR: couldn't open file\n");
                abort();
            }
            muxer = new MediaMuxer(fd, MediaMuxer::OUTPUT_FORMAT_MPEG_4);
            close(fd);
            if (gRotate) {
                muxer->setOrientationHint(90);  // TODO: does this do anything?
            }
+10 −1
Original line number Diff line number Diff line
@@ -14,6 +14,10 @@
 * limitations under the License.
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <binder/ProcessState.h>
#include <media/mediarecorder.h>
#include <media/stagefright/foundation/ADebug.h>
@@ -109,7 +113,12 @@ int main(int argc, char* argv[])

    if (fileOut != NULL) {
        // target file specified, write encoded AMR output
        sp<AMRWriter> writer = new AMRWriter(fileOut);
        int fd = open(fileOut, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
        if (fd < 0) {
            return 1;
        }
        sp<AMRWriter> writer = new AMRWriter(fd);
        close(fd);
        writer->addSource(encoder);
        writer->start();
        sleep(duration);
+11 −1
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "muxer"
#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <utils/Log.h>

#include <binder/ProcessState.h>
@@ -72,8 +75,15 @@ static int muxing(
    ALOGV("input file %s, output file %s", path, outputFileName);
    ALOGV("useAudio %d, useVideo %d", useAudio, useVideo);

    sp<MediaMuxer> muxer = new MediaMuxer(outputFileName,
    int fd = open(outputFileName, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);

    if (fd < 0) {
        ALOGE("couldn't open file");
        return fd;
    }
    sp<MediaMuxer> muxer = new MediaMuxer(fd,
                                          MediaMuxer::OUTPUT_FORMAT_MPEG_4);
    close(fd);

    size_t trackCount = extractor->countTracks();
    // Map the extractor's track index to the muxer's track index.
+11 −1
Original line number Diff line number Diff line
@@ -17,6 +17,10 @@
#include "SineSource.h"

#include <inttypes.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <binder/ProcessState.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/AudioPlayer.h>
@@ -300,7 +304,13 @@ int main(int argc, char **argv) {
                client.interface(), enc_meta, true /* createEncoder */, source,
                0, preferSoftwareCodec ? OMXCodec::kPreferSoftwareCodecs : 0);

    sp<MPEG4Writer> writer = new MPEG4Writer(fileName);
    int fd = open(fileName, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
    if (fd < 0) {
        fprintf(stderr, "couldn't open file");
        return 1;
    }
    sp<MPEG4Writer> writer = new MPEG4Writer(fd);
    close(fd);
    writer->addSource(encoder);
    int64_t start = systemTime();
    CHECK_EQ((status_t)OK, writer->start());
+8 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>

//#define LOG_NDEBUG 0
#define LOG_TAG "stagefright"
@@ -506,8 +508,13 @@ static void writeSourcesToMP4(
    sp<MPEG4Writer> writer =
        new MPEG4Writer(gWriteMP4Filename.string());
#else
    int fd = open(gWriteMP4Filename.string(), O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
    if (fd < 0) {
        fprintf(stderr, "couldn't open file");
        return;
    }
    sp<MPEG2TSWriter> writer =
        new MPEG2TSWriter(gWriteMP4Filename.string());
        new MPEG2TSWriter(fd);
#endif

    // at most one minute.
Loading