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

Commit f5a83856 authored by James Dong's avatar James Dong
Browse files

Image encoding settings java API through xml configuration file

- I decided to completely remove jpeg decoding related stuff from this change
  I think that setting is better off if it is specified by the system properties.
  We don't have to include MediaProfiles.h header in skia files
parent df49e892
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public:
     * or -1 if error.
     *
     * Supported param name are:
     * duration - the recording duration.
     * file.format - output file format. see mediarecorder.h for details
     * vid.codec - video encoder. see mediarecorder.h for details.
     * aud.codec - audio encoder. see mediarecorder.h for details.
@@ -120,6 +121,16 @@ public:
      */
    Vector<audio_decoder> getAudioDecoders() const;

    /**
     * Returns the number of image encoding quality levels supported.
     */
    Vector<int> getImageEncodingQualityLevels() const;

    /**
     * Returns the maximum amount of memory in bytes we can use for decoding a JPEG file.
     */
    int getImageDecodingMaxMemory() const;

private:
    MediaProfiles& operator=(const MediaProfiles&);  // Don't call me
    MediaProfiles(const MediaProfiles&);             // Don't call me
@@ -257,6 +268,8 @@ private:
    static VideoEncoderCap* createVideoEncoderCap(const char **atts);
    static AudioEncoderCap* createAudioEncoderCap(const char **atts);
    static CamcorderProfile* createCamcorderProfile(const char **atts);
    static int getImageEncodingQualityLevel(const char **atts);
    static int getImageDecodingMaxMemory(const char **atts);

    // Customized element tag handler for parsing the xml configuration file.
    static void startElementHandler(void *userData, const char *name, const char **atts);
@@ -271,6 +284,8 @@ private:
    static void createDefaultVideoDecoders(MediaProfiles *profiles);
    static void createDefaultAudioDecoders(MediaProfiles *profiles);
    static void createDefaultEncoderOutputFileFormats(MediaProfiles *profiles);
    static void createDefaultImageEncodingQualityLevels(MediaProfiles *profiles);
    static void createDefaultImageDecodingMaxMemory(MediaProfiles *profiles);
    static VideoEncoderCap* createDefaultH263VideoEncoderCap();
    static VideoEncoderCap* createDefaultM4vVideoEncoderCap();
    static AudioEncoderCap* createDefaultAmrNBEncoderCap();
@@ -295,6 +310,8 @@ private:
    Vector<AudioDecoderCap*>  mAudioDecoders;
    Vector<VideoDecoderCap*>  mVideoDecoders;
    Vector<output_format>     mEncoderOutputFileFormats;
    Vector<int>               mImageEncodingQualityLevels;
    int                       mImageDecodingMaxMemory;
};

}; // namespace android
+24 −0
Original line number Diff line number Diff line
@@ -293,6 +293,13 @@ MediaProfiles::createCamcorderProfile(const char **atts)
    return profile;
}

/*static*/ int
MediaProfiles::getImageEncodingQualityLevel(const char** atts)
{
    CHECK(!strcmp("quality", atts[0]));
    return atoi(atts[1]);
}

/*static*/ void
MediaProfiles::startElementHandler(void *userData, const char *name, const char **atts)
{
@@ -317,6 +324,8 @@ MediaProfiles::startElementHandler(void *userData, const char *name, const char
        profiles->mEncoderOutputFileFormats.add(createEncoderOutputFileFormat(atts));
    } else if (strcmp("EncoderProfile", name) == 0) {
        profiles->mCamcorderProfiles.add(createCamcorderProfile(atts));
    } else if (strcmp("ImageEncoding", name) == 0) {
        profiles->mImageEncodingQualityLevels.add(getImageEncodingQualityLevel(atts));
    }
}

@@ -446,6 +455,14 @@ MediaProfiles::createDefaultAmrNBEncoderCap()
        AUDIO_ENCODER_AMR_NB, 5525, 12200, 8000, 8000, 1, 1);
}

/*static*/ void
MediaProfiles::createDefaultImageEncodingQualityLevels(MediaProfiles *profiles)
{
    profiles->mImageEncodingQualityLevels.add(70);
    profiles->mImageEncodingQualityLevels.add(80);
    profiles->mImageEncodingQualityLevels.add(90);
}

/*static*/ MediaProfiles*
MediaProfiles::createDefaultInstance()
{
@@ -456,6 +473,7 @@ MediaProfiles::createDefaultInstance()
    createDefaultVideoDecoders(profiles);
    createDefaultAudioDecoders(profiles);
    createDefaultEncoderOutputFileFormats(profiles);
    createDefaultImageEncodingQualityLevels(profiles);
    sIsInitialized = true;
    return profiles;
}
@@ -627,6 +645,7 @@ int MediaProfiles::getCamcorderProfileParamByName(const char *name, camcorder_qu
        return -1;
    }

    if (!strcmp("duration", name)) return mCamcorderProfiles[index]->mDuration;
    if (!strcmp("file.format", name)) return mCamcorderProfiles[index]->mFileFormat;
    if (!strcmp("vid.codec", name)) return mCamcorderProfiles[index]->mVideoCodec->mCodec;
    if (!strcmp("vid.width", name)) return mCamcorderProfiles[index]->mVideoCodec->mFrameWidth;
@@ -642,6 +661,11 @@ int MediaProfiles::getCamcorderProfileParamByName(const char *name, camcorder_qu
    return -1;
}

Vector<int> MediaProfiles::getImageEncodingQualityLevels() const
{
    return mImageEncodingQualityLevels;  // copy out
}

MediaProfiles::~MediaProfiles()
{
    CHECK("destructor should never be called" == 0);