From de15b8c160c720c48b93796016801e7ae0b6bd2d Mon Sep 17 00:00:00 2001 From: Ray Essick Date: Tue, 30 Jan 2018 16:35:56 -0800 Subject: [PATCH] link media.metrics native strings to api-controlled java strings add comments to native media.metrics code pointing to how they are (and aren't) to be kept in synch with their java counterparts that are part of the public API (and therefore pretty much fixed). Bug: 72492234 Test: compilation Change-Id: Ic096545a5cdfb2160c6b66438d345d8e625384b9 --- media/libaudioclient/AudioRecord.cpp | 7 +++-- media/libaudioclient/AudioTrack.cpp | 5 ++++ .../nuplayer2/NuPlayer2Driver.cpp | 5 ++++ .../StagefrightRecorder.cpp | 28 +++++++++++-------- .../nuplayer/NuPlayerDriver.cpp | 5 ++++ media/libstagefright/MediaCodec.cpp | 14 +++++++--- media/libstagefright/RemoteMediaExtractor.cpp | 5 +++- 7 files changed, 50 insertions(+), 19 deletions(-) diff --git a/media/libaudioclient/AudioRecord.cpp b/media/libaudioclient/AudioRecord.cpp index 6b3a8f02ca..21d3fa666c 100644 --- a/media/libaudioclient/AudioRecord.cpp +++ b/media/libaudioclient/AudioRecord.cpp @@ -91,11 +91,14 @@ void AudioRecord::MediaMetrics::gather(const AudioRecord *record) { // key for media statistics is defined in the header // attrs for media statistics - static constexpr char kAudioRecordChannelCount[] = "android.media.audiorecord.channels"; + // NB: these are matched with public Java API constants defined + // in frameworks/base/media/java/android/media/AudioRecord.java + // These must be kept synchronized with the constants there. static constexpr char kAudioRecordEncoding[] = "android.media.audiorecord.encoding"; + static constexpr char kAudioRecordSource[] = "android.media.audiorecord.source"; static constexpr char kAudioRecordLatency[] = "android.media.audiorecord.latency"; static constexpr char kAudioRecordSampleRate[] = "android.media.audiorecord.samplerate"; - static constexpr char kAudioRecordSource[] = "android.media.audiotrack.source"; + static constexpr char kAudioRecordChannelCount[] = "android.media.audiorecord.channels"; // constructor guarantees mAnalyticsItem is valid diff --git a/media/libaudioclient/AudioTrack.cpp b/media/libaudioclient/AudioTrack.cpp index 55954f244e..d6cc5e8a4e 100644 --- a/media/libaudioclient/AudioTrack.cpp +++ b/media/libaudioclient/AudioTrack.cpp @@ -185,11 +185,16 @@ void AudioTrack::MediaMetrics::gather(const AudioTrack *track) // key for media statistics is defined in the header // attrs for media statistics + // NB: these are matched with public Java API constants defined + // in frameworks/base/media/java/android/media/AudioTrack.java + // These must be kept synchronized with the constants there. static constexpr char kAudioTrackStreamType[] = "android.media.audiotrack.streamtype"; static constexpr char kAudioTrackContentType[] = "android.media.audiotrack.type"; static constexpr char kAudioTrackUsage[] = "android.media.audiotrack.usage"; static constexpr char kAudioTrackSampleRate[] = "android.media.audiotrack.samplerate"; static constexpr char kAudioTrackChannelMask[] = "android.media.audiotrack.channelmask"; + + // NB: These are not yet exposed as public Java API constants. static constexpr char kAudioTrackUnderrunFrames[] = "android.media.audiotrack.underrunframes"; static constexpr char kAudioTrackStartupGlitch[] = "android.media.audiotrack.glitch.startup"; diff --git a/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp b/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp index 2a1e904301..607d40660a 100644 --- a/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp +++ b/media/libmediaplayer2/nuplayer2/NuPlayer2Driver.cpp @@ -79,6 +79,9 @@ private: // key for media statistics static const char *kKeyPlayer = "nuplayer"; // attrs for media statistics + // NB: these are matched with public Java API constants defined + // in frameworks/base/media/java/android/media/MediaPlayer2.java + // These must be kept synchronized with the constants there. static const char *kPlayerVMime = "android.media.mediaplayer.video.mime"; static const char *kPlayerVCodec = "android.media.mediaplayer.video.codec"; static const char *kPlayerWidth = "android.media.mediaplayer.width"; @@ -91,6 +94,8 @@ static const char *kPlayerDuration = "android.media.mediaplayer.durationMs"; static const char *kPlayerPlaying = "android.media.mediaplayer.playingMs"; static const char *kPlayerError = "android.media.mediaplayer.err"; static const char *kPlayerErrorCode = "android.media.mediaplayer.errcode"; + +// NB: These are not yet exposed as public Java API constants. static const char *kPlayerErrorState = "android.media.mediaplayer.errstate"; static const char *kPlayerDataSourceType = "android.media.mediaplayer.dataSource"; // diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp index bc8d8c8f9c..5cbf976235 100644 --- a/media/libmediaplayerservice/StagefrightRecorder.cpp +++ b/media/libmediaplayerservice/StagefrightRecorder.cpp @@ -69,22 +69,26 @@ static const int kMaxNumVideoTemporalLayers = 8; // key for media statistics static const char *kKeyRecorder = "recorder"; // attrs for media statistics -static const char *kRecorderHeight = "android.media.mediarecorder.height"; -static const char *kRecorderWidth = "android.media.mediarecorder.width"; -static const char *kRecorderFrameRate = "android.media.mediarecorder.frame-rate"; -static const char *kRecorderVideoBitrate = "android.media.mediarecorder.video-bitrate"; -static const char *kRecorderAudioSampleRate = "android.media.mediarecorder.audio-samplerate"; -static const char *kRecorderAudioChannels = "android.media.mediarecorder.audio-channels"; +// NB: these are matched with public Java API constants defined +// in frameworks/base/media/java/android/media/MediaRecorder.java +// These must be kept synchronized with the constants there. static const char *kRecorderAudioBitrate = "android.media.mediarecorder.audio-bitrate"; -static const char *kRecorderVideoIframeInterval = "android.media.mediarecorder.video-iframe-interval"; -static const char *kRecorderMovieTimescale = "android.media.mediarecorder.movie-timescale"; +static const char *kRecorderAudioChannels = "android.media.mediarecorder.audio-channels"; +static const char *kRecorderAudioSampleRate = "android.media.mediarecorder.audio-samplerate"; static const char *kRecorderAudioTimescale = "android.media.mediarecorder.audio-timescale"; -static const char *kRecorderVideoTimescale = "android.media.mediarecorder.video-timescale"; -static const char *kRecorderVideoProfile = "android.media.mediarecorder.video-encoder-profile"; -static const char *kRecorderVideoLevel = "android.media.mediarecorder.video-encoder-level"; -static const char *kRecorderCaptureFpsEnable = "android.media.mediarecorder.capture-fpsenable"; static const char *kRecorderCaptureFps = "android.media.mediarecorder.capture-fps"; +static const char *kRecorderCaptureFpsEnable = "android.media.mediarecorder.capture-fpsenable"; +static const char *kRecorderFrameRate = "android.media.mediarecorder.frame-rate"; +static const char *kRecorderHeight = "android.media.mediarecorder.height"; +static const char *kRecorderMovieTimescale = "android.media.mediarecorder.movie-timescale"; static const char *kRecorderRotation = "android.media.mediarecorder.rotation"; +static const char *kRecorderVideoBitrate = "android.media.mediarecorder.video-bitrate"; +static const char *kRecorderVideoIframeInterval = "android.media.mediarecorder.video-iframe-interval"; +static const char *kRecorderVideoLevel = "android.media.mediarecorder.video-encoder-level"; +static const char *kRecorderVideoProfile = "android.media.mediarecorder.video-encoder-profile"; +static const char *kRecorderVideoTimescale = "android.media.mediarecorder.video-timescale"; +static const char *kRecorderWidth = "android.media.mediarecorder.width"; + // To collect the encoder usage for the battery app static void addBatteryData(uint32_t params) { diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp index b3fd00a6e4..c4559515d2 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp @@ -43,6 +43,9 @@ namespace android { // key for media statistics static const char *kKeyPlayer = "nuplayer"; // attrs for media statistics + // NB: these are matched with public Java API constants defined + // in frameworks/base/media/java/android/media/MediaPlayer.java + // These must be kept synchronized with the constants there. static const char *kPlayerVMime = "android.media.mediaplayer.video.mime"; static const char *kPlayerVCodec = "android.media.mediaplayer.video.codec"; static const char *kPlayerWidth = "android.media.mediaplayer.width"; @@ -55,6 +58,8 @@ static const char *kPlayerDuration = "android.media.mediaplayer.durationMs"; static const char *kPlayerPlaying = "android.media.mediaplayer.playingMs"; static const char *kPlayerError = "android.media.mediaplayer.err"; static const char *kPlayerErrorCode = "android.media.mediaplayer.errcode"; + + // NB: These are not yet exposed as public Java API constants. static const char *kPlayerErrorState = "android.media.mediaplayer.errstate"; static const char *kPlayerDataSourceType = "android.media.mediaplayer.dataSource"; // diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp index 56ac3ed16f..db07afe2ab 100644 --- a/media/libstagefright/MediaCodec.cpp +++ b/media/libstagefright/MediaCodec.cpp @@ -64,16 +64,22 @@ namespace android { // key for media statistics static const char *kCodecKeyName = "codec"; // attrs for media statistics +// NB: these are matched with public Java API constants defined +// in frameworks/base/media/java/android/media/MediaCodec.java +// These must be kept synchronized with the constants there. static const char *kCodecCodec = "android.media.mediacodec.codec"; /* e.g. OMX.google.aac.decoder */ static const char *kCodecMime = "android.media.mediacodec.mime"; /* e.g. audio/mime */ static const char *kCodecMode = "android.media.mediacodec.mode"; /* audio, video */ +static const char *kCodecModeVideo = "video"; /* values returned for kCodecMode */ +static const char *kCodecModeAudio = "audio"; +static const char *kCodecEncoder = "android.media.mediacodec.encoder"; /* 0,1 */ static const char *kCodecSecure = "android.media.mediacodec.secure"; /* 0, 1 */ -static const char *kCodecHeight = "android.media.mediacodec.height"; /* 0..n */ static const char *kCodecWidth = "android.media.mediacodec.width"; /* 0..n */ +static const char *kCodecHeight = "android.media.mediacodec.height"; /* 0..n */ static const char *kCodecRotation = "android.media.mediacodec.rotation-degrees"; /* 0/90/180/270 */ -static const char *kCodecCrypto = "android.media.mediacodec.crypto"; /* 0,1 */ -static const char *kCodecEncoder = "android.media.mediacodec.encoder"; /* 0,1 */ +// NB: These are not yet exposed as public Java API constants. +static const char *kCodecCrypto = "android.media.mediacodec.crypto"; /* 0,1 */ static const char *kCodecBytesIn = "android.media.mediacodec.bytesin"; /* 0..n */ static const char *kCodecProfile = "android.media.mediacodec.profile"; /* 0..n */ static const char *kCodecLevel = "android.media.mediacodec.level"; /* 0..n */ @@ -645,7 +651,7 @@ status_t MediaCodec::init(const AString &name, bool nameIsType, bool encoder) { } else { mAnalyticsItem->setCString(kCodecCodec, name.c_str()); } - mAnalyticsItem->setCString(kCodecMode, mIsVideo ? "video" : "audio"); + mAnalyticsItem->setCString(kCodecMode, mIsVideo ? kCodecModeVideo : kCodecModeAudio); if (nameIsType) mAnalyticsItem->setInt32(kCodecEncoder, encoder); } diff --git a/media/libstagefright/RemoteMediaExtractor.cpp b/media/libstagefright/RemoteMediaExtractor.cpp index d1907807be..5bb0953998 100644 --- a/media/libstagefright/RemoteMediaExtractor.cpp +++ b/media/libstagefright/RemoteMediaExtractor.cpp @@ -32,9 +32,12 @@ namespace android { static const char *kKeyExtractor = "extractor"; // attrs for media statistics +// NB: these are matched with public Java API constants defined +// in frameworks/base/media/java/android/media/MediaExtractor.java +// These must be kept synchronized with the constants there. +static const char *kExtractorFormat = "android.media.mediaextractor.fmt"; static const char *kExtractorMime = "android.media.mediaextractor.mime"; static const char *kExtractorTracks = "android.media.mediaextractor.ntrk"; -static const char *kExtractorFormat = "android.media.mediaextractor.fmt"; RemoteMediaExtractor::RemoteMediaExtractor( MediaExtractor *extractor,