diff options
Diffstat (limited to 'media')
| -rw-r--r-- | media/libmedia/MediaProfiles.cpp | 59 | ||||
| -rw-r--r-- | media/libstagefright/AwesomePlayer.cpp | 72 | ||||
| -rw-r--r-- | media/libstagefright/codecs/on2/dec/SoftVPX.cpp | 2 | ||||
| -rw-r--r-- | media/libstagefright/include/AwesomePlayer.h | 3 | ||||
| -rw-r--r-- | media/libstagefright/omx/OMXNodeInstance.cpp | 2 | 
5 files changed, 117 insertions, 21 deletions
diff --git a/media/libmedia/MediaProfiles.cpp b/media/libmedia/MediaProfiles.cpp index f0f07a2..5a8bc60 100644 --- a/media/libmedia/MediaProfiles.cpp +++ b/media/libmedia/MediaProfiles.cpp @@ -26,6 +26,7 @@  #include <expat.h>  #include <media/MediaProfiles.h>  #include <media/stagefright/MediaDebug.h> +#include <media/stagefright/openmax/OMX_Video.h>  namespace android { @@ -377,7 +378,24 @@ void MediaProfiles::addStartTimeOffset(int cameraId, const char** atts)      LOGV("%s: cameraId=%d, offset=%d ms", __func__, cameraId, offsetTimeMs);      mStartTimeOffsets.replaceValueFor(cameraId, offsetTimeMs);  } +/*static*/ MediaProfiles::ExportVideoProfile* +MediaProfiles::createExportVideoProfile(const char **atts) +{ +    CHECK(!strcmp("name", atts[0]) && +          !strcmp("profile", atts[2]) && +          !strcmp("level", atts[4])); + +    const size_t nMappings = +        sizeof(sVideoEncoderNameMap)/sizeof(sVideoEncoderNameMap[0]); +    const int codec = findTagForName(sVideoEncoderNameMap, nMappings, atts[1]); +    CHECK(codec != -1); + +    MediaProfiles::ExportVideoProfile *profile = +        new MediaProfiles::ExportVideoProfile( +            codec, atoi(atts[3]), atoi(atts[5])); +    return profile; +}  /*static*/ MediaProfiles::VideoEditorCap*  MediaProfiles::createVideoEditorCap(const char **atts, MediaProfiles *profiles)  { @@ -428,6 +446,8 @@ MediaProfiles::startElementHandler(void *userData, const char *name, const char          profiles->addImageEncodingQualityLevel(profiles->mCurrentCameraId, atts);      } else if (strcmp("VideoEditorCap", name) == 0) {          createVideoEditorCap(atts, profiles); +    } else if (strcmp("ExportVideoProfile", name) == 0) { +        profiles->mVideoEditorExportProfiles.add(createExportVideoProfile(atts));      }  } @@ -830,6 +850,20 @@ MediaProfiles::createDefaultVideoEditorCap(MediaProfiles *profiles)                  VIDEOEDITOR_DEFAULT_MAX_OUTPUT_FRAME_WIDTH,                  VIDEOEDITOR_DEFUALT_MAX_OUTPUT_FRAME_HEIGHT);  } +/*static*/ void +MediaProfiles::createDefaultExportVideoProfiles(MediaProfiles *profiles) +{ +    // Create default video export profiles +    profiles->mVideoEditorExportProfiles.add( +        new ExportVideoProfile(VIDEO_ENCODER_H263, +            OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level10)); +    profiles->mVideoEditorExportProfiles.add( +        new ExportVideoProfile(VIDEO_ENCODER_MPEG_4_SP, +            OMX_VIDEO_MPEG4ProfileSimple, OMX_VIDEO_MPEG4Level1)); +    profiles->mVideoEditorExportProfiles.add( +        new ExportVideoProfile(VIDEO_ENCODER_H264, +            OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13)); +}  /*static*/ MediaProfiles*  MediaProfiles::createDefaultInstance() @@ -843,6 +877,7 @@ MediaProfiles::createDefaultInstance()      createDefaultEncoderOutputFileFormats(profiles);      createDefaultImageEncodingQualityLevels(profiles);      createDefaultVideoEditorCap(profiles); +    createDefaultExportVideoProfiles(profiles);      return profiles;  } @@ -940,7 +975,31 @@ int MediaProfiles::getVideoEncoderParamByName(const char *name, video_encoder co      LOGE("The given video encoder param name %s is not found", name);      return -1;  } +int MediaProfiles::getVideoEditorExportParamByName( +    const char *name, int codec) const +{ +    LOGV("getVideoEditorExportParamByName: name %s codec %d", name, codec); +    ExportVideoProfile *exportProfile = NULL; +    int index = -1; +    for (size_t i =0; i < mVideoEditorExportProfiles.size(); i++) { +        exportProfile = mVideoEditorExportProfiles[i]; +        if (exportProfile->mCodec == codec) { +            index = i; +            break; +        } +    } +    if (index == -1) { +        LOGE("The given video decoder %d is not found", codec); +        return -1; +    } +    if (!strcmp("videoeditor.export.profile", name)) +        return exportProfile->mProfile; +    if (!strcmp("videoeditor.export.level", name)) +        return exportProfile->mLevel; +    LOGE("The given video editor export param name %s is not found", name); +    return -1; +}  int MediaProfiles::getVideoEditorCapParamByName(const char *name) const  {      LOGV("getVideoEditorCapParamByName: %s", name); diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp index 99242ab..f2673b3 100644 --- a/media/libstagefright/AwesomePlayer.cpp +++ b/media/libstagefright/AwesomePlayer.cpp @@ -59,6 +59,7 @@  #include <cutils/properties.h>  #define USE_SURFACE_ALLOC 1 +#define FRAME_DROP_FREQ 0  namespace android { @@ -548,7 +549,7 @@ void AwesomePlayer::reset_l() {      mVideoTimeUs = 0;      mSeeking = NO_SEEK; -    mSeekNotificationSent = false; +    mSeekNotificationSent = true;      mSeekTimeUs = 0;      mUri.setTo(""); @@ -820,7 +821,12 @@ void AwesomePlayer::onStreamDone() {          return;      } -    if (mFlags & (LOOPING | AUTO_LOOPING)) { +    if ((mFlags & LOOPING) +            || ((mFlags & AUTO_LOOPING) +                && (mAudioSink == NULL || mAudioSink->realtime()))) { +        // Don't AUTO_LOOP if we're being recorded, since that cannot be +        // turned off and recording would go on indefinitely. +          seekTo_l(0);          if (mVideoSource != NULL) { @@ -1204,7 +1210,6 @@ void AwesomePlayer::setNativeWindow_l(const sp<ANativeWindow> &native) {      if (mLastVideoTimeUs >= 0) {          mSeeking = SEEK; -        mSeekNotificationSent = true;          mSeekTimeUs = mLastVideoTimeUs;          modifyFlags((AT_EOS | AUDIO_AT_EOS | VIDEO_AT_EOS), CLEAR);      } @@ -1305,8 +1310,10 @@ void AwesomePlayer::OnRTSPSeekDoneWrapper(void *cookie) {  }  void AwesomePlayer::onRTSPSeekDone() { -    notifyListener_l(MEDIA_SEEK_COMPLETE); -    mSeekNotificationSent = true; +    if (!mSeekNotificationSent) { +        notifyListener_l(MEDIA_SEEK_COMPLETE); +        mSeekNotificationSent = true; +    }  }  status_t AwesomePlayer::seekTo_l(int64_t timeUs) { @@ -1518,14 +1525,29 @@ status_t AwesomePlayer::initVideoDecoder(uint32_t flags) {      }      if (mVideoSource != NULL) { -        Mutex::Autolock autoLock(mStatsLock); -        TrackStat *stat = &mStats.mTracks.editItemAt(mStats.mVideoTrackIndex); - -        const char *component; +        const char *componentName;          CHECK(mVideoSource->getFormat() -                ->findCString(kKeyDecoderComponent, &component)); +                ->findCString(kKeyDecoderComponent, &componentName)); -        stat->mDecoderName = component; +        { +            Mutex::Autolock autoLock(mStatsLock); +            TrackStat *stat = &mStats.mTracks.editItemAt(mStats.mVideoTrackIndex); + +            stat->mDecoderName = componentName; +        } + +        static const char *kPrefix = "OMX.Nvidia."; +        static const char *kSuffix = ".decode"; +        static const size_t kSuffixLength = strlen(kSuffix); + +        size_t componentNameLength = strlen(componentName); + +        if (!strncmp(componentName, kPrefix, strlen(kPrefix)) +                && componentNameLength >= kSuffixLength +                && !strcmp(&componentName[ +                    componentNameLength - kSuffixLength], kSuffix)) { +            modifyFlags(SLOW_DECODER_HACK, SET); +        }      }      return mVideoSource != NULL ? OK : UNKNOWN_ERROR; @@ -1705,6 +1727,7 @@ void AwesomePlayer::onVideoEvent() {      if (mFlags & FIRST_FRAME) {          modifyFlags(FIRST_FRAME, CLEAR); +        mSinceLastDropped = 0;          mTimeSourceDeltaUs = ts->getRealTimeUs() - timeUs;      } @@ -1751,18 +1774,28 @@ void AwesomePlayer::onVideoEvent() {          if (latenessUs > 40000) {              // We're more than 40ms late. -            LOGV("we're late by %lld us (%.2f secs), dropping frame", +            LOGV("we're late by %lld us (%.2f secs)",                   latenessUs, latenessUs / 1E6); -            mVideoBuffer->release(); -            mVideoBuffer = NULL; +            if (!(mFlags & SLOW_DECODER_HACK) +                    || mSinceLastDropped > FRAME_DROP_FREQ)              { -                Mutex::Autolock autoLock(mStatsLock); -                ++mStats.mNumVideoFramesDropped; -            } +                LOGV("we're late by %lld us (%.2f secs) dropping " +                     "one after %d frames", +                     latenessUs, latenessUs / 1E6, mSinceLastDropped); -            postVideoEvent_l(); -            return; +                mSinceLastDropped = 0; +                mVideoBuffer->release(); +                mVideoBuffer = NULL; + +                { +                    Mutex::Autolock autoLock(mStatsLock); +                    ++mStats.mNumVideoFramesDropped; +                } + +                postVideoEvent_l(); +                return; +            }          }          if (latenessUs < -10000) { @@ -1781,6 +1814,7 @@ void AwesomePlayer::onVideoEvent() {      }      if (mVideoRenderer != NULL) { +        mSinceLastDropped++;          mVideoRenderer->render(mVideoBuffer);      } diff --git a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp index 7e83163..61a02ac 100644 --- a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp +++ b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp @@ -66,7 +66,7 @@ void SoftVPX::initPorts() {      def.eDir = OMX_DirInput;      def.nBufferCountMin = kNumBuffers;      def.nBufferCountActual = def.nBufferCountMin; -    def.nBufferSize = 8192; +    def.nBufferSize = 256 * 1024;      def.bEnabled = OMX_TRUE;      def.bPopulated = OMX_FALSE;      def.eDomain = OMX_PortDomainVideo; diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h index 95f2ae8..14476d3 100644 --- a/media/libstagefright/include/AwesomePlayer.h +++ b/media/libstagefright/include/AwesomePlayer.h @@ -141,6 +141,8 @@ private:          TEXT_RUNNING        = 0x10000,          TEXTPLAYER_STARTED  = 0x20000, + +        SLOW_DECODER_HACK   = 0x40000,      };      mutable Mutex mLock; @@ -181,6 +183,7 @@ private:      uint32_t mFlags;      uint32_t mExtractorFlags; +    uint32_t mSinceLastDropped;      int64_t mTimeSourceDeltaUs;      int64_t mVideoTimeUs; diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp index d7467d5..b612f89 100644 --- a/media/libstagefright/omx/OMXNodeInstance.cpp +++ b/media/libstagefright/omx/OMXNodeInstance.cpp @@ -419,7 +419,7 @@ status_t OMXNodeInstance::useGraphicBuffer2_l(      def.nVersion.s.nStep = 0;      def.nPortIndex = portIndex;      OMX_ERRORTYPE err = OMX_GetParameter(mHandle, OMX_IndexParamPortDefinition, &def); -    if (err != OK) +    if (err != OMX_ErrorNone)      {          LOGE("%s::%d:Error getting OMX_IndexParamPortDefinition", __FUNCTION__, __LINE__);          return err;  | 
