75 Commits

Author SHA1 Message Date
Chih-Yu Huang
a77c8dff43 MediaMetadataRetriever: Fix null pointer exception
This CL fixes a null pointer exception by adding a null check.

Bug: 170357507
Test: run android.media.cts.ThumbnailUtilsTest and no crash
Change-Id: I60645e4382700993ff7e1bc992b970d89b5b600e
(cherry picked from commit fc24bd264ef1f599efa834fc120bc6d1ed304af3)
2020-12-11 09:12:50 +00:00
Zim
95c8a18133 Avoid transcoding in MediaPlayers
Test: Manual
Bug: 158466177
Change-Id: I71776e1e81002b1505f5094c92fdd10706d1268e
2020-10-20 22:26:22 +01:00
Orion Hodson
329c612e3d Update to use nativehelper/JNIPlatformHelp.h
Reflects refactoring of JNI helper code that depends on private
methods within libnativehelper.

Bug: 151443957
Test: Treehugger
Change-Id: I7af128f42ae89a77a8e3fb113ea533331153c535
2020-06-23 11:50:20 +01:00
Marco Nelissen
0b291937b4 MediaMetadataRetriever: parse genre tags
When the genre tag is numeric, return a human readable string instead
of the raw numeric tag.

Bug: 141520122
Test: CTS
Change-Id: Ida0d48171e1400b87940e4e38aa07d2fdd5a77ed
2020-01-15 07:37:27 -08:00
Derek Sollenberger
213dacabd0 Update MediaMetadateRetriever to use android graphic's C APIs.
This is part of the effort to stabilize the ABI of the android
graphics package so that it can be contained within an APEX module.

Test: CtsMediaTestCases
Bug: 137655431
Change-Id: Ifdd6083ad18a73df819fadc36823ddc3027b7049
2019-11-06 15:50:05 -05:00
Chong Zhang
435e59d934 Add BitmapParams option to getFrameAtTime/getScaledFrameAtTime
Add versions of these two methods that accepts BitmapParams.
Does not change spec or behavior of existing getFrameAtTime/
getScaledFrameAtTime.

bug: 135718180
bug: 138114267
test: CTS MediaMetadataRetrieverTest; manual testing with
thumbnails saved to storage and examine the outputs.

Change-Id: I75e96dde072c94ac950f0be637cdd096e7543f10
2019-10-08 19:50:17 +00:00
Ytai Ben-Tsvi
2c9d8f6db0 Improve visibility of IMemory security risks
This change renames the IMemory raw pointer accessors to
unsecure*() to make it apparent to coders and code reviewers
that the returned buffer may potentially be shared with
untrusted processes, who may, after the fact, attempt to
read and/or modify the contents. This may lead to hard to
find security bugs and hopefully the rename makes it harder
to forget.

The change also attempts to fix all the callsites to make
everything build correctly, but in the processes, wherever the
callsite code was not obviously secure, I added a TODO requesting
the owners to either document why it's secure or to change the
code. Apologies in advance to the owners if there are some false
positives here - I don't have enough context to reason about all
the different callsites.

Test: Completely syntactic change. Made sure code still builds.
Change-Id: I4c555ef8c8c47cf28b42b17ad8b4021a783548cd
2019-09-13 11:05:09 -07:00
Chong Zhang
5d3913335c Retrieve one frame at a time sequentially
Use getFrameAtIndex sequentially and retrieve one frame at a time,
MediaMetadataRetriever internally will reuse the decoder and frame
memory in this case. This is as efficient and holds up less shared
memory (as we only need one temp frame).

bug: 120414514
Change-Id: I58ddc5df63edaf480875ce2651bf18a037793aad
2019-07-12 11:42:07 -07:00
Jooyung Han
cb1e896d57 Extract android_media_Utils.cpp as a lib
This is a part of job to cut dependency from libmediandk
to libandroid_runtime. As a LL-NDK, libmediandk desn't have
to depend on libandroid_runtime.

dependency: libmediandk -> libmedia_jni -> libandroid_runtime

Libmediandk calls three utility functions defined in
android_media_Utils.cpp. But these functions are independent
from libandroid_runtime.

By extracting those utility functions into its own shared library
(libmedia_jni_utils), the dependency from libmediandk to
libmedia_jni is cut down.

However, some classes and other functions in android_media_Utils.cpp
are moved into new file, android_media_Streams.cpp since they
depend on libandroid_runtime.

Bug: 124268753
Test: m -j
Change-Id: I1e1ea4bc1ff7022d8d9c42785c8c00e3ca153a50
2019-02-22 08:47:24 +00:00
Chong Zhang
7d12714020 Use heif embedded thumbnail if available
Use the heif embedded thumbnail as long as it's not
too small to avoid decoding the full image and downscale.

bug: 74395267
Test: CTS MediaMetadataRetriever test; manual test of thumbnail
extraction by browsing new folders containing heif files in
Downloads app.
Change-Id: I5b2be0521452376153a773cb7671fefe7f9bc439
2018-04-12 00:08:57 +00:00
Chong Zhang
6c8512978a heif: address api review comments
- renaming of MediaFormat keys related to grid config

- add methods to MediaMetadataRetriever to get image/frame
  with default bitmap config

- fix java doc

bug: 74831433

Change-Id: Iec607e615d34bea0620070592e4adcfc04cbccae
2018-03-15 15:05:29 -07:00
Chong Zhang
a89f6e1bb2 heif: add option for specifying bitmap pixel format
Add an option similar to BitmapFactory.Options to the bitmap
extraction APIs added in P to allow the app to specify bitmap's
pixel format. MediaMetadataRetriever's old getFrameAtTime()
only allows extraction in RGB565, for image use case the bitdepth
could be too low.

Also change return type of getFramesAtIndex to List as
Lint is complaining about returning raw arrays.

bug: 63633199
bug: 73886998

Change-Id: I40f0a421c767483e32c7744180dc5a187681e066
2018-03-12 21:23:00 +00:00
Marco Nelissen
463ec6b40c Clean up MediaMetadataRetriever use
MediaMetaRetriever derives from RefBase, so we should treat it as such.

Bug: 30816425
Test: build, boot, CTS
Change-Id: Ifa089636c5d997cd9e17bf23b9e5f49a7ee2cbed
2018-01-10 14:00:29 -08:00
Chong Zhang
4342f08fab heif: support heif image sequence and dual-function files
- Add a few methods to MediaMetadataRetriever to get still
  images and frames by index.

- Declare keys in MediaFormat related to heif still images.

bug: 63633199

test:
cts-tradefed run cts-dev --module CtsMediaTestCases --compatibility:module-arg CtsMediaTestCases:include-annotation:android.platform.test.annotations.RequiresDevice

Change-Id: I9556b27f7395a163aadd01e979930061878994d0
2017-10-30 19:59:43 +00:00
Hangyu Kuang
0552036bc8 media: Add scaled video thumbnail extractor api.
Bug: 62198298
Test: CTS test
Change-Id: Ic78e2dac38b596a10d2fae76bc22f8c43fadf444
2017-07-27 13:31:46 -07:00
Steven Moreland
9f430b2782 Merge "frameworks/base: use proper nativehelper headers" am: 826eafd958 am: 5c091dc944
am: c840945a78

Change-Id: I654e14f0d1b495450db81592a2e564e308746350
2017-07-20 03:05:02 +00:00
Steven Moreland
2279b25342 frameworks/base: use proper nativehelper headers
libnativehelper exports headers under nativehelper. These were
available before incorrectly as global headers in order to give
access to jni.h.

Test: modules using frameworks/base find headers
Bug: 63762847
Change-Id: I0f9f231acdebe460f279135462f43d3e32eff64d
2017-07-19 10:06:40 -07:00
Mike Reed
7c0ae0f58b bitmaps and pixelrefs no longer need lock/unlock
Test: covered by CtsGraphicsTestCases and hwui_unit_tests

Change-Id: I42a25961a2eb3755d2fd22a617aa21a24ec0994f
2017-04-18 10:22:42 -04:00
Elliott Hughes
b57dd722f1 resolved conflicts for a884d81e to stage-aosp-master
Change-Id: Ice485967fa96f13786024b6939b826638e906ff0
2015-09-24 10:01:32 -07:00
Daniel Micay
76f6a86de2 constify JNINativeMethod function pointer tables
Change-Id: I4036c924958221cbc644724f8eb01c5de3cd7954
2015-09-22 17:10:35 -04:00
John Reck
ed207b9274 Change how Java Bitmaps are accessed in a few places
Stop assuming that a Java Bitmap has a SkBitmap* that
has some externally managed lifecycle, and instead switch
a bunch of users to accessing the bitmap by providing
their own SkBitmap* on which to set the (ref counted!)
SkPixelRef* instead

Attempt #2 to land this, original issue was in getSkBitmap
and should be fixed

Change-Id: I0fd9e193968b41e5597784140d56b4885906864a
2015-04-30 12:46:57 -07:00
John Reck
8222a7ec81 Merge "Revert "Change how Java Bitmaps are accessed in a few places"" 2015-04-20 22:07:45 +00:00
John Reck
edc22fba59 Revert "Change how Java Bitmaps are accessed in a few places"
Bug: 20207616

This reverts commit a771b9861d11671c780092d35c0062eeefcf37c0.

Change-Id: Ifd891cc075274a7986e987229e0fed5a04ed9ff0
2015-04-20 22:06:31 +00:00
Chris Watkins
4eaa293808 Unhide the android.media.[Media]DataSource interface.
This allows apps to implement MediaDataSource, which is modeled on
stagefright's DataSource, to supply media data to the framework. This
was already implemented for MediaExtractor, but it was renamed from
DataSource.

MediaExtractor, MediaPlayer and MediaMetadataRetriever each have a new
overload: #setDataSource(android.media.MediaDataSource)

Only NuPlayer supports this new data source.

The change introduces:
 * IDataSource:        The binder interface for DataSource.
 * JMediaDataSource:   The native counterpart to the java interface. It
                       implements IDataSource.
 * CallbackDataSource: A stagefright DataSource that wraps an IDataSource.

Change-Id: I6d9c1167b4a7384c469b1e928f31791a7ebed716
2015-04-15 16:33:15 -07:00
John Reck
a771b9861d Change how Java Bitmaps are accessed in a few places
Stop assuming that a Java Bitmap has a SkBitmap* that
has some externally managed lifecycle, and instead switch
a bunch of users to accessing the bitmap by providing
their own SkBitmap* on which to set the (ref counted!)
SkPixelRef* instead

Change-Id: I0fd9e193968b41e5597784140d56b4885906864a
2015-04-13 09:50:42 -07:00
John Reck
f4faeac352 Cleanup Bitmap JNI attempt #2
Original version missed a spot

This reverts commit c02977e3bbfaaedcb1b1d67e1692becc7dddd59b.

Change-Id: I56244ce10d709fcdef42a001fe4c6ba7b6bbb04d
2015-03-05 13:56:16 -08:00
Chad Jones
c02977e3bb Revert "Cleanup Bitmap JNI"
This reverts commit b2915245b74b3b5541b123e38403f8e26426b4b7.

Change-Id: Idd7d7f33eec4ea5024c83de6b10d3d1a6ab2b17a
2015-03-05 19:34:26 +00:00
John Reck
b2915245b7 Cleanup Bitmap JNI
Fix a bunch of places where mNativeBitmap was being
poked at directly, switch them either to the NDK API
or to GraphicsJNI where it made sense

Change-Id: I6b3df3712d6497cba828c2d3012e725cb4ebb64d
2015-03-05 09:55:02 -08:00
Chih-hung Hsieh
17a0826e5d am b0dd6d3a: am 4c23a0ec: Merge "Adjust format strings to work on both 32-bit and 64-bit builds"
automerge: d1aa67b

* commit 'd1aa67b8e19ae96bd2ae4e6719d13902a8b6d845':
  Adjust format strings to work on both 32-bit and 64-bit builds
2014-12-11 21:05:00 +00:00
Bernhard Rosenkränzer
46c82b4cd2 Adjust format strings to work on both 32-bit and 64-bit builds
Adjust format strings to not produce Clang warnings in both 32-bit and
64-bit builds

Change-Id: I76c29d8d5d0fb4b5e9d9518077652370ffe9e871
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
2014-12-05 16:14:07 -08:00
Andreas Gampe
baa73b056c am cba06c22: resolved conflicts for merge of 6957369d to lmp-mr1-dev-plus-aosp
* commit 'cba06c2272c8bce7d10b2a7ee762d12043f3252a':
  Frameworks/base: Wall Werror in media/jni
2014-11-11 04:02:22 +00:00
Andreas Gampe
5a15d0d31b Frameworks/base: Wall Werror in media/jni
Turn on -Wall -Werror in media/jni. Fix warnings.

Change-Id: I9da54ad379d8172ee535b52ee2b0637a2533f4e3
2014-11-10 18:19:40 -08:00
Mike Reed
021a3443c6 SkBitmap::Config is deprecated
Change-Id: I0bbd929074474ae3c1d497c2f645417e4876d9e3
2014-08-14 09:57:06 -04:00
Elliott Hughes
f4c6a154e9 am b9525871: am 8525fe8d: am 1a3908e9: Merge "Switch to a type-safe album art interface."
* commit 'b952587184572070805243e6f8380ceb769f441c':
  Switch to a type-safe album art interface.
2014-06-12 00:15:38 +00:00
Elliott Hughes
95d3f86fed Switch to a type-safe album art interface.
(Requires a matching change in frameworks/av.)

Bug: 15514223
Change-Id: I4e494cc5d7a2eb82cd2b7ae3b829fc663136267a
2014-06-11 14:43:57 -07:00
Marco Nelissen
ae84e20b2a am 4375e848: am ab962b54: am ab3977d2: Merge "MetadataRetriever: Check null pointer to avoid tombstone crash."
* commit '4375e84882a9a84b0012cf9504a30ede6ef72c1f':
  MetadataRetriever: Check null pointer to avoid tombstone crash.
2014-05-01 15:35:31 +00:00
wang, biao
c847a4835b MetadataRetriever: Check null pointer to avoid tombstone crash.
When the app's vm-heap is not enough, memory allocation for big
object like bitmap may failed.

This patch add protection for bitmap creating to avoid segment
fault error in the following GetIntField function.

Change-Id: I63977dc602f4ed395afd11004a0ed027173fb685
Signed-off-by: wang, biao <biao.wang@intel.com>
Signed-off-by: TingX Li <tingx.li@intel.com>
Signed-off-by: Wang LiangX <liangx.wang@intel.com>
2014-04-09 18:56:48 +08:00
Narayan Kamath
6ae7cd063b am f2c11c14: am 214c3d9b: am 6ac6263d: am 28ccb4f7: Merge "Don\'t use size_t for variables that store uint32_t value"
* commit 'f2c11c142975f1571a0e8606a3b274afcb987b83':
  Don't use size_t for variables that store uint32_t value
2014-03-07 20:22:13 +00:00
Ashok Bhat
58fad0bf14 Don't use size_t for variables that store uint32_t value
The local variables width, height, displayWidth and
displayHeight are set to the corresponding members
of VideoFrame class. As the members of VideoFrame are
uint32_t, the local variables have been changed to
uint32_t.

As these local variables are passed to a java method,
the change of size_t to uint32_t ensures that the size
of the actual parameter (i.e uint32_t) is now same as
the size of the formal parameter (i.e. jint) for all
platforms.

Change-Id: Icd14de0142bfd4e6ba52a3e6aff3d80b323a0de4
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
2014-03-06 11:33:20 +00:00
Derek Sollenberger
eece0dda56 Fix includes so that they no longer rely on the global Skia includes directories.
bug:13225538
Change-Id: Ia5d816dc665f81c7985f21036af4fd0a63c560cf
2014-02-27 14:31:29 -05:00
Andreas Huber
d2506a5063 FINAL ATTEMPT: HTTP services are now provided from JAVA and made available to media code
Change-Id: I7f6cdcfd2a28846d36d89dd5180ef20a22b03af8
2014-02-04 14:45:28 -08:00
Ashok Bhat
a0398430fc AArch64: Make graphics classes 64-bit compatible
Changes in this patch include

[x] Long is used to store native pointers as they can
    be 64-bit.

[x] Some minor changes have been done to conform with
    standard JNI practice (e.g. use of jint instead of int
    in JNI function prototypes)

[x] AssetAtlasManager is not completely 64-bit compatible
    yet. Specifically mAtlasMap member has to be converted
    to hold native pointer using long. Added a TODO to
    AssetAtlasManager.java to indicate the change required.

Change-Id: I940433f601c6db998c1a8ffff338f5361200d5ed
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Craig Barber <craig.barber@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
2014-01-28 17:40:38 +00:00
Ashok Bhat
36bef0bf30 AArch64: Make graphics classes 64-bit compatible
This a merger of two commits submitted to AOSP by
the following authors:

ashok.bhat@arm.com, david.butcher@arm.coma
craig.barber@arm.com, kevin.petit@arm.com and
marcus.oakland@arm.com

Due to the very large number of internal conflicts, I
have chosen to cherry-pick this change instead
of letting it merge through AOSP because the merge
conflict resolution would be very hard to review.

Commit messages below:

================================================
AArch64: Make graphics classes 64-bit compatible

Changes in this patch include

[x] Long is used to store native pointers as they can
    be 64-bit.

[x] Some minor changes have been done to conform with
    standard JNI practice (e.g. use of jint instead of int
    in JNI function prototypes)

[x] AssetAtlasManager is not completely 64-bit compatible
    yet. Specifically mAtlasMap member has to be converted
    to hold native pointer using long. Added a TODO to
    AssetAtlasManager.java to indicate the change required.

Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Craig Barber <craig.barber@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>

==================================================================

AArch64: Use long for pointers in graphics/Camera

For storing pointers, long is used in
android/graphics/Camera class, as native
pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use of
jint instead of int in JNI function prototypes)

Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>

===================================================================

Change-Id: Id5793fa0ebc17ee8b1eecf4b3f327977fdccff71
2014-01-28 10:02:43 +00:00
Narayan Kamath
7023df08f1 Revert "AArch64: Make graphics classes 64-bit compatible"
This reverts commit 18b4cbeedef21c1fa666a110a157bab66edff976.

Change-Id: I0c52983a3ab1ace3ff743de546a43eca28e5cb0e
2014-01-27 14:22:45 +00:00
Ashok Bhat
18b4cbeede AArch64: Make graphics classes 64-bit compatible
This a merger of two commits submitted to AOSP by
the following authors:

ashok.bhat@arm.com, david.butcher@arm.coma
craig.barber@arm.com, kevin.petit@arm.com and
marcus.oakland@arm.com

Due to the very large number of internal conflicts, I
have chosen to cherry-pick this change instead
of letting it merge through AOSP because the merge
conflict resolution would be very hard to review.

Commit messages below:

================================================
AArch64: Make graphics classes 64-bit compatible

Changes in this patch include

[x] Long is used to store native pointers as they can
    be 64-bit.

[x] Some minor changes have been done to conform with
    standard JNI practice (e.g. use of jint instead of int
    in JNI function prototypes)

[x] AssetAtlasManager is not completely 64-bit compatible
    yet. Specifically mAtlasMap member has to be converted
    to hold native pointer using long. Added a TODO to
    AssetAtlasManager.java to indicate the change required.

Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Craig Barber <craig.barber@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>

==================================================================

AArch64: Use long for pointers in graphics/Camera

For storing pointers, long is used in
android/graphics/Camera class, as native
pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use of
jint instead of int in JNI function prototypes)

Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>

===================================================================

Change-Id: Ib3eab85ed97ea3e3c227617c20f8d213f17d4ba0
2014-01-27 13:28:16 +00:00
Ashok Bhat
075e9a19ce AArch64: Use long for pointers in media classes
For storing pointers, long is used in media classes,
as native pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use
of jint instead of int in JNI function prototypes)

Change-Id: Idc4ca0124d03df7f9cef412488abafd020e5e774
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
2014-01-15 13:09:27 +00:00
James Dong
0041b5c561 Fix thumbnail generation failure
o Change the impl of MediaMetadataRetriever.setDataSource(String).
  It opens and passes an fd to the media framework
  rather than pass the file path directly to the media server. The change is needed since media
  server does not have read permission to sdcard
o Remove the unnecessary jni method

Change-Id: I5a2f47dde804523d264b588f855ba2575a99c179
2012-04-11 14:56:34 -07:00
Steve Block
3762c31172 Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/#/c/157220

Bug: 5449033
Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
2012-01-08 13:19:13 +00:00
Steve Block
71f2cf116a Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/#/c/143865

Bug: 5449033
Change-Id: I0122812ed6ff6f5b59fe4a43ab8bff0577adde0a
2011-10-26 09:57:54 +01:00
James Dong
79f407cc6c Refactor to share code between MediaPlayer and MediaMetadataRetriever JNI
Change-Id: Ib847213f566dee79126d7c14d00750a9a8dedeb9
2011-05-05 15:11:23 -07:00