CPM Authentication Interface

29 views
Skip to first unread message

Hedge

unread,
Aug 31, 2009, 8:51:32 PM8/31/09
to android-platform
Hi all,

In the doc "Content Policy Manager Developer's Guide", section 4.2
(Authentication Interface) mentions that the "interface provides for
optional challenge request so each side can verify the identity of the
other with a higher degree of confidence".

This sounds excellent, however, I can't find anything else in the
document or source code that shows how to do this. Could someone
please explain the overview of how this system works?

Thanks,
~Andrew

Hedge

unread,
Sep 1, 2009, 2:22:55 PM9/1/09
to android-platform
For more info:
I have already tried passing some authentication data from the parser
node to the cpm plugin... from what I understand from the sample MP4
parser node code, the parser's OpenCPMSession() calls the CPM
manager's OpenSession() function. This trickles down to DoOpenSession
(), which calls AuthenticateWithAllRegisteredPlugIns() and
AuthenticateUser(sessionId, pluginData, contextData) on the CPM
plugin. I don't see how pluginData gets filled though... there
doesn't seem to be a way to send data from the parser node to the CPM
plugin because OpenSession() only takes a session ID and a context
pointer, and DoOpenSession() discards the context pointer.

RaviY

unread,
Sep 2, 2009, 12:52:25 AM9/2/09
to android-platform
The sequence goes something like this ...

-- Parser node creats a CPM module.
-- CPM loads all active CPM plugins.
-- Parser node does an Init of CPM.
-- Here, the CPM plugin will be queried for it's authentication
data (pluginData).
-- Parser node dos a CPM OpenSession.
-- Here, the pluginData is used along with the sessionId previously
assigned.

I am not sure what you mean by "DoOpenSession" discards the context
pointer. Did you want to send this context data to the plugin? The
usage of the context data is only to "identify" the async command that
has returned.

-Ravi

Hedge

unread,
Sep 2, 2009, 2:29:30 PM9/2/09
to android-platform
Hi Ravi,

Thank you for your quick reply and the overview. I am confused when
you say that the CPM plugin is queried for its authentication data.
That sounds like the CPM plugin provides its auth data to the CPM
module, then in OpenSession the engine sends the CPM plugin's own auth
data back to it.

In the CPM dev guide, it seems to me in section 3.1.2 that the
authentication interface is used to authenticate the _user_. In
section 4.2, it sounds like the authentication interface is used for
the parser and the CPM plugin to authenticate each other.
Understanding which it is would help a lot ;)

What I meant by DoOpenSession discarding the data is that I thought
the parser would send data to the plugin to identify the user (as in
3.1.2).

In summary, is there a way for the CPM plugin to identify the parser
node as trusted?
Which description matches what AuthenticateUser and the authentication
interface do?
In the diagram in 3.2.2, how does the "Parser content file to retrieve
DRM Info" DRM info get to the plugin? The sample plugin reads the
file itself.

I apologize for all the questions... I am trying my best to understand
how it all works through the documentation and source code.

RaviY

unread,
Sep 2, 2009, 3:22:24 PM9/2/09
to android-platform
I mis-spoke: The authentication data is queried from the CPM plugin
container, and not the CPM plugin.

So, this is how it was intended to work ... when there is an interest
to use a CPM plugin, the user is expected to instantiate a CPM plugin
container, which will take in as input parameters, (a) the interface
to the CPM plugin and (b) the authentication data (both provided by
the user). And, after going through the steps discussed above, we
would pass this "authentication data" to the CPM plugin.

The documentation in section 4.2 does sound convoluted :). I shall
check if I can get that updated. I confirm that the trust is between
the "user" and the "CPM plugin".

I am not sure if I understood your last question correctly or not:
Typically the source nodes, as part of iCPM->RegisterContent(), pass
in "source data". This reaches the plugin in
SetSourceInitializationData. The source data could be of a form that
the source node and plugin have a mutual understanding of. One may
choose to use the various "source context data" that are available.
Ofcourse, as in the case of the oma1 passthru plugin example, the
filename could also be sent directly.

-Ravi

RaviY

unread,
Sep 2, 2009, 3:27:42 PM9/2/09
to android-platform
That being said, it looks like we may have broken that feature.

-Ravi

Hedge

unread,
Sep 10, 2009, 1:04:06 PM9/10/09
to android-platform
Thanks Ravi for clearing up the authentication confusion. And (oh
no!), where was it broken? I don't see any mention of
CPMPluginContainers in the oma1 passthru or kmj cpm plugins, but I
will try using them.

One more thing - where in the CPM sequence can the human user respond
to dialog prompts? For example, if drm/license-type is "count", how
can the Splitter or CPM plugin warn the user that they are about to
use up their last play count and ask them if they wish to do so?

Thanks for your help,
~Andrew
Message has been deleted
Message has been deleted

RaviY

unread,
Sep 10, 2009, 2:26:55 PM9/10/09
to android-platform


On Sep 10, 12:04 pm, Hedge <awoo...@gmail.com> wrote:
> Thanks Ravi for clearing up the authentication confusion.  And (oh
> no!), where was it broken?  I don't see any mention of
> CPMPluginContainers in the oma1 passthru or kmj cpm plugins, but I
> will try using them.
The CPMPluginContainers was the old way of registering CPM plugins. It
might still work, but I haven't used it in a while. The trick is, to
use this container, you might have to link your DRM library with the
libopencore_player.so (essentially playerdriver.cpp).

>
> One more thing - where in the CPM sequence can the human user respond
> to dialog prompts?  For example, if drm/license-type is "count", how
> can the Splitter or CPM plugin warn the user that they are about to
> use up their last play count and ask them if they wish to do so?
The best place is after PVPlayerEngine::Init(). At this point, the
app. can query for the metadata and present it to the user.

Hedge

unread,
Sep 10, 2009, 5:30:58 PM9/10/09
to android-platform
Thanks for your response, Ravi. It doesn't look like the
CPMPluginContainer would work because in cpm.cpp, _AddPluginInstance
initializes the authentication data to NULL. The parser wouldn't have
direct access to the CPM plugin either since it interfaces with
PVMFCPM. The is no set method in the container class either.

I am also unclear about how "the best place is after
PVPlayerEngine::Init()". Did you not mean immediately after? From my
PV logs it looks like PVPlayerEngine::DoInit returns before the parser
node starts its DoInit, and the parser DoInit is where InitCPM is
called. The earliest that the CPM plugin would know how many play-
counts are left is after it knows what file it is playing, which
wouldn't be until AuthenticateUser (if the CPMPluginContainer method
works) or SetSourceInitializationData (if not).

...Or did you mean that CPM initialization should occur before it does
in the MP4 parser example (e.g. in Parser::SetSourceInitializationData
instead of Parser::Init, OpenSession, RegisterContent, etc.) I don't
know how this would work with embedded DRM schemes that require the
parser to be initialized first.

RaviY

unread,
Sep 11, 2009, 10:09:08 AM9/11/09
to android-platform


On Sep 10, 4:30 pm, Hedge <awoo...@gmail.com> wrote:
> Thanks for your response, Ravi.  It doesn't look like the
> CPMPluginContainer would work because in cpm.cpp, _AddPluginInstance
> initializes the authentication data to NULL.  The parser wouldn't have
> direct access to the CPM plugin either since it interfaces with
> PVMFCPM.  The is no set method in the container class either.
>
Something like this should -technically- work ...
OSCL_StackString<100> mimestring("rk-mime");
PVMFCPMPluginInterface* rkIface = iPluginFactory->CreateCPMPlugin
();
CPMPluginContainer* rkcontainer = new CPMPluginContainer(*rkIface,
NULL);
CPMPluginRegistry* rkReg =
CPMPluginRegistryFactory::CreateCPMPluginRegistry();
rkReg->addPluginToRegistry(mimestring, *rkcontainer);
However, let me take an action item on myself to get this reworked.
Looks like there are a few problems to be addressed. I would suggest
you to not spend time on this now. I shall update you when it is
ready.

> I am also unclear about how "the best place is after
> PVPlayerEngine::Init()".  Did you not mean immediately after?  From my
> PV logs it looks like PVPlayerEngine::DoInit returns before the parser
> node starts its DoInit, and the parser DoInit is where InitCPM is
> called.  The earliest that the CPM plugin would know how many play-
> counts are left is after it knows what file it is playing, which
> wouldn't be until AuthenticateUser (if the CPMPluginContainer method
> works) or SetSourceInitializationData (if not).
>
> ...Or did you mean that CPM initialization should occur before it does
> in the MP4 parser example (e.g. in Parser::SetSourceInitializationData
> instead of Parser::Init, OpenSession, RegisterContent, etc.)  I don't
> know how this would work with embedded DRM schemes that require the
> parser to be initialized first.
By "the best place is after PVPlayerEngine::Init()", I meant after the
command has completed (asynchronously).

Hedge

unread,
Sep 11, 2009, 2:54:59 PM9/11/09
to android-platform
Ok, I gotcha. Thanks for figuring that out. I'm confident I can work
around the limitations for now.

One last thing... could you point me to how to tell the player to
create a dialog?
For calls made from Java code (e.g. MediaPlayer::prepare()), it looks
like android_media_MediaPlayer.cpp contains JNI code (e.g.
android_media_MediaPlayer_prepare) and PlayerDriver::Run
(playerdriver.cpp) handles the calls and sends commands down to
PVPlayerEngine (e.g. DoPrepare()). It returns status via
EngineCommandCompleted to the status observer. I get a little lost in
the sequence, and I'm not sure which class has the observer though.

How does it work in reverse, e.g. sending notifications back to the
player engine and alerting the Java app that the user needs to
respond? It would probably need to interrupt the prepare() sequence
and ask the user for feedback, and then upon receiving the response,
the engine continues processing the file.

I'm not asking for a complete solution, but if you could get me
started with an overview of how notifications can be sent back and
forth and user input can influence the player engine, I'd be really
grateful.

Thanks,
~Andrew
> > > > todialogprompts?  For example, if drm/license-type is "count", how

Hedge

unread,
Sep 11, 2009, 6:02:18 PM9/11/09
to android-platform
I should really clarify that post...

Can the Engine create a dialog that the user can respond to, or does
it pass an event up to the Application which displays a dialog? I can
display a dialog in an Android app, but I'm not sure how events bubble
up (OnInfoListener?) or how the engine could create a dialog.

How are user responses returned to the engine?

Thanks
> > > > > > > > authentication interface is used toauthenticatethe _user_.  In
> > > > > > > > section 4.2, it sounds like the authentication interface is used for
> > > > > > > > the parser and the CPM plugin toauthenticateeach other.
> ...
>
> read more »

Hedge

unread,
Sep 15, 2009, 2:47:06 PM9/15/09
to android-platform
Maybe android.media.MediaMetadataRetriever would work if I could query
the file play count before playback starts. I see code for it, and
unit tests, but it's not importable and doesn't appear in
android.jar. Is it gone for good?

This post (http://groups.google.com/group/android-developers/
browse_thread/thread/f73a8891065912e4) implies that everything but
captureFrame should still work.

This post (http://groups.google.com/group/android-platform/
browse_thread/thread/37420d36f13915f7/3371be3ef72b878d?
lnk=gst&q=MediaMetadataRetriever#3371be3ef72b878d) says it's not a
public API. So how can metadata (besides width and height) be
retrieved for encrypted video files?

Another option I'm considering if this isn't available is to use
MediaScanner and add a new parseMYMIMETYPE to processFile(). This
takes action on a whole directory though, not a single file. And it
doesn't allow for MIME types of dynamically loaded parsers.
> ...
>
> read more »

RaviY

unread,
Sep 15, 2009, 4:00:39 PM9/15/09
to android-platform
Yes. Unfortunately, the MediaPlayer APIs currently do not provide a
way to retrieve arbitrary metadata. There is a proposal to add an API
like "getMetadata" to retrieve arbitary set of metadata. However,
there will still be a problem for a usecase such as yours where you
want to retrieve the metadata after PVPlayerEngine::Init() and before
PVPlayerEngine::Prepare().

Using the MediaMetadataRetriever ... this is not a published API. So,
I guess you will not be able to write a portable application that is
guaranteed to work on all devices.

Using the MediaScanner ... this is tricky because for .mp4, .mp3
files, the CPM plugin will not be loaded. Instead, calls are made
directly to the mp4/mp3 parser libraries to retrieve the metadata.

If you are going to use your own version of Android codebase, you may
modify the codebase to get around all the limitations above. If not, I
would suggest you to propose required changes/additions in the APIs
and the usecases that they would cover.

-Ravi
> ...
>
> read more »

NoraBora

unread,
Sep 18, 2009, 5:08:29 AM9/18/09
to android-platform
Wow. This thread is exactly what I've been looking for.
I implemented cpm plugins (dynamically loading from .cfg) and
succeeded in playing descrypted music files, which took me a lot of
time...OTL
The next step is to show users a popup about count or expiration date.

At first I thought adding a member function something like getDRMInfo
() in MediaPlayer.java
because there is already getDuration() which does a similar job using
GetMetadataValue.
but what I want is not am int but a string and strings always make
memory tricky. so I looked for a better solution...

...and yesterday I found MediaMetadataRetriever.java. what a beautiful
thing it is!
but today I found I can't import
android.media.MediaMetadataRetriever... what a sad story..

--------------------- Here comes my first question
If I don't mind my app is portable or not, how can I use
MediaMetadataRetriever with SDK & emulator?

Recently I also found something interesting in OpenCORE 2.05.
They are 'pvme' (opencore/engines/pvme) and'
PVPlayerExtHandler' (opencore/android/PVPlayerExtHandler.cpp).
I think they can be useful for me but I can't find any example or
documents about them.

--------------------- Second & Third question.
Is there any references about 'pvme & PVPlayerExtHandler'?
Can they help me implement getDRMInfo()?


I hope Hedge and RaviY are still interested in this topic.


On Sep 16, 5:00 am, RaviY <yend...@pv.com> wrote:
> Yes. Unfortunately, the MediaPlayer APIs currently do not provide a
> way to retrieve arbitrarymetadata. There is a proposal to add an API
> like "getMetadata" to retrieve arbitary set ofmetadata. However,
> there will still be a problem for a usecase such as yours where you
> want to retrieve themetadataafter PVPlayerEngine::Init() and before
> PVPlayerEngine::Prepare().
>
> Using the MediaMetadataRetriever ... this is not a published API. So,
> I guess you will not be able to write a portable application that is
> guaranteed to work on all devices.
>
> Using the MediaScanner ... this is tricky because for .mp4, .mp3
> files, the CPM plugin will not be loaded. Instead, calls are made
> directly to the mp4/mp3 parser libraries to retrieve themetadata.
>
> If you are going to use your own version of Android codebase, you may
> modify the codebase to get around all the limitations above. If not, I
> would suggest you to propose required changes/additions in the APIs
> and the usecases that they would cover.
>
> -Ravi
>
> On Sep 15, 1:47 pm, Hedge <awoo...@gmail.com> wrote:
>
> > Maybe android.media.MediaMetadataRetriever would work if I could query
> > the file play count before playback starts.  I see code for it, and
> > unit tests, but it's not importable and doesn't appear in
> > android.jar.  Is it gone for good?
>
> > This post (http://groups.google.com/group/android-developers/
> > browse_thread/thread/f73a8891065912e4) implies that everything but
> > captureFrame should still work.
>
> > This post (http://groups.google.com/group/android-platform/
> > browse_thread/thread/37420d36f13915f7/3371be3ef72b878d?
> > lnk=gst&q=MediaMetadataRetriever#3371be3ef72b878d) says it's not a
> > public API.  So how canmetadata(besides width and height) be
> > > > > > > app. can query for themetadataand present it to the user.
> ...
>
> read more »

RaviY

unread,
Sep 20, 2009, 9:39:00 AM9/20/09
to android-platform
- As mentioned above, with the current order of events in the SDK
below, there is no good place, that I can think of, for the app. to
show the user the DRM information before consuming an additional count
of license. We will arrive at a solution soon.
- One way, which is very kludgy, to achieve what you are trying to do
is .. (a) user selects a clip, (b) you start a MediaMetadataRetriever
and retrieve the required metadata to show the user, (c) show a dialog
box to the user, and (d) when user says "continue", you start a
MediaPlayer.
- PVME is the Metadata Engine. This is a special engine designed for
fast retrieval of arbitrary metadata. This is -not- intended to be
used with the MediaPlayer. It is meant to be used with the
MediaMetadataRetriever.
- PVPlayerExtHandler is a class that is being designed to pass random
commands, that are not part of the MediaPlayer api. MediaPlayer will
be added a new API called "invoke", which will take as input a Parcel.
The underlying player extension handler, decodes the parcel and
figures out what kind of API to be used. More on that later.

-Ravi
> ...
>
> read more »

Hyeong-Ho Yoo

unread,
Sep 20, 2009, 10:15:13 PM9/20/09
to android-...@googlegroups.com
Thank you for your quick reply, RaviY.

You suggested using MediaMetadataRetriever but I can't import it in emulator.
(I'm working with windows xp emulator & sdk 1.5r3)
How can I use unpublished API?

If it is not possible to import, I think of adding a extractMetadata method to MediaPlayer.java by myself..
Because using MediaMetadataRetriever and MediaPlayer seems ineffective for me.(file open twice, init twice, close twice) MediaPlayer.getDuration & MediaMetadataRetriever.extractMetadata will be good references, I guess...

Or is this a solution you mentioned below('We will arrive at a solution soon.), hopefully..? merging MediaMetadataRetriever to MediaPlayer?

2009/9/20 RaviY <yen...@pv.com>

Hedge

unread,
Sep 21, 2009, 1:03:12 PM9/21/09
to android-platform
As Ravi and I said, MediaMetadataRetriever is not a public API, so you
can't just import it into your app. However, if you have access to
the source (i.e. on the emulator, or you're working with an OEM) you
can add it manually. Here's how I added it to my emulator
environment:
To use MediaMetadataRetriever, compile it with JAVAC
e.g. javac -classpath ".;...\android-1.5\android.jar" android\media
\MediaMetadataRetriever.java
Then add the class file to the android.jar file with JAR.
e.g. jar uf android.jar android\media\MediaMetadataRetriever.class

I agree, we need a way to access metadata from the MediaPlayer class.
Otherwise what is the point of having metadata and implementing the
MetadataInterface? I am very interested in hearing more about this
PVPlayerExtHandler.

On Sep 20, 7:15 pm, Hyeong-Ho Yoo <noranb...@gmail.com> wrote:
> Thank you for your quick reply, RaviY.
>
> You suggested using MediaMetadataRetriever but I can't import it in
> emulator.
> (I'm working with windows xp emulator & sdk 1.5r3)
> How can I use unpublished API?
>
> If it is not possible to import, I think of adding a extractMetadata method
> to MediaPlayer.java by myself..
> Because using MediaMetadataRetriever and MediaPlayer seems ineffective for
> me.(file open twice, init twice, close twice) MediaPlayer.getDuration &
> MediaMetadataRetriever.extractMetadata will be good references, I guess...
>
> Or is this a solution you mentioned below('We will arrive at a solution
> soon.), hopefully..? merging MediaMetadataRetriever to MediaPlayer?
>
> 2009/9/20 RaviY <yend...@pv.com>
> read more »

Hedge

unread,
Sep 21, 2009, 1:14:07 PM9/21/09
to android-platform
@NoraBora - Yes, I'm glad we're not the only ones interested in this
topic!

PVPlayerExtHandler sounds interesting, but adding an arbitrary
getMetadataValue(String query) to MediaPlayer would seem the easiest
solution (similar to MediaPlayer's getDuration, getVideoHeight, etc.)
Maybe there is a good reason why this wouldn't work or is inelegant?
> ...
>
> read more »

RaviY

unread,
Sep 21, 2009, 5:28:32 PM9/21/09
to android-platform


On Sep 21, 12:14 pm, Hedge <awoo...@gmail.com> wrote:
> @NoraBora - Yes, I'm glad we're not the only ones interested in this
> topic!
>
> PVPlayerExtHandler sounds interesting, but adding an arbitrary
> getMetadataValue(String query) to MediaPlayer would seem the easiest
> solution (similar to MediaPlayer's getDuration, getVideoHeight, etc.)
> Maybe there is a good reason why this wouldn't work or is inelegant?
There is one in works already.
> ...
>
> read more »

NoraBora

unread,
Sep 30, 2009, 3:48:37 AM9/30/09
to android-platform
I wanted to change the code as less as possible to I tried to use
MediaMetadataRetriever and
I found an easier way to import MediaMetadataRetriever or any non-
public api.

1. remove {@hide} in MediaMetadataRetriever.java (so it can be a
public class like MediaPlayer.)
2. m or make in mydroid root (this build will take a while.)
3. make update-api (this script copies mydroid/out/target/common/obj/
PACKAGING/public_api.xml to mydroid/frameworks/base/api/current.xml)
4. replace sdk's android.jar with mydroid/out/target/common/obj/
JAVA_LIBRARIES/android_stubs_current_intermediates/javalib.jar

now you can use MediaMetadataRetriever in eclipse.

But when I try to use MediaMetadataRetriever, I found something
strange.

1. MediaMetadataRetriever.java's setMode(value) calls
metadatadriver.cpp's setMode(value),
but framemetadatautility doesn't use this value but uses
PV_FRAME_METADATA_INTERFACE_MODE_SOURCE_METADATA_AND_THUMBNAIL.

2. I happend to make a small bug in my cpm plugin so it returned
PVMFFailure in DoReset().
Because of this PVMFFailure, PVPlayerEngine::HandleSourceNodeReset
never calls RunIfNotReady() and the whole process stops.
I think whether DoReset returns PVMFSuccess or not,
PVPlayerEngine::HandleSourceNodeReset should call RunIfNotReady() so
PVPlayerEngine::Run() can be called.

3. MediaMetadataRetriever.setDataSource() calls cpm plugin's
UsageComplete. This is quite frustrating to me... I don't want
MediaMetadataRetriever to decrease the drm count. I don't know if I
can tell I actually playback the content or just get metadata of it.

Unless the third issue is solved, I will try the way to add getMetadata
() method in MediaPlayer.java and modify related files (jni,
opencore).

If there is any better way, Please tell me...


On Sep 22, 6:28 am, RaviY <yend...@pv.com> wrote:
> On Sep 21, 12:14 pm, Hedge <awoo...@gmail.com> wrote:> @NoraBora - Yes, I'm glad we're not the only ones interested in this
> > topic!
>
> > PVPlayerExtHandler sounds interesting, but adding an arbitrary
> > getMetadataValue(String query) to MediaPlayer would seem the easiest
> > solution (similar to MediaPlayer's getDuration, getVideoHeight, etc.)
> > Maybe there is a good reason why this wouldn't work or is inelegant?
>
> There is one in works already.
>
>
>
> > On Sep 21, 10:03 am, Hedge <awoo...@gmail.com> wrote:
>
> > > As Ravi and I said, MediaMetadataRetriever is not a public API, so you
> > > can't just import it into your app.  However, if you have access to
> > > the source (i.e. on the emulator, or you're working with an OEM) you
> > > can add it manually.  Here's how I added it to my emulator
> > > environment:
> > > To use MediaMetadataRetriever, compile it with JAVAC
> > >   e.g. javac -classpath ".;...\android-1.5\android.jar" android\media
> > > \MediaMetadataRetriever.java
> > > Then add the class file to the android.jar file with JAR.
> > >   e.g. jar uf android.jar android\media\MediaMetadataRetriever.class
>
> > > I agree, we need a way to accessmetadatafrom the MediaPlayer class.
> > > Otherwise what is the point of havingmetadataand implementing the
> > > MetadataInterface?  I am very interested in hearing more about this
> > > PVPlayerExtHandler.
>
> > > On Sep 20, 7:15 pm, Hyeong-Ho Yoo <noranb...@gmail.com> wrote:
>
> > > > Thank you for your quick reply, RaviY.
>
> > > > You suggested using MediaMetadataRetriever but I can't import it in
> > > > emulator.
> > > > (I'm working with windows xp emulator & sdk 1.5r3)
> > > > How can I use unpublished API?
>
> > > > If it is not possible to import, I think of adding a extractMetadata method
> > > > to MediaPlayer.java by myself..
> > > > Because using MediaMetadataRetriever and MediaPlayer seems ineffective for
> > > > me.(file open twice, init twice, close twice) MediaPlayer.getDuration &
> > > > MediaMetadataRetriever.extractMetadata will be good references, I guess...
>
> > > > Or is this a solution you mentioned below('We will arrive at a solution
> > > > soon.), hopefully..? merging MediaMetadataRetriever to MediaPlayer?
>
> > > > 2009/9/20 RaviY <yend...@pv.com>
>
> > > > > - As mentioned above, with the current order of events in the SDK
> > > > > below, there is no good place, that I can think of, for the app. to
> > > > > show the user the DRM information before consuming an additional count
> > > > > of license. We will arrive at a solution soon.
> > > > > - One way, which is very kludgy, to achieve what you are trying to do
> > > > > is .. (a) user selects a clip, (b) you start a MediaMetadataRetriever
> > > > > and retrieve the requiredmetadatato show the user, (c) show a dialog
> > > > > box to the user, and (d) when user says "continue", you start a
> > > > > MediaPlayer.
> > > > > - PVME is theMetadataEngine. This is a special engine designed for
> > > > > fast retrieval of arbitrarymetadata. This is -not- intended to be
> ...
>
> read more »

RaviY

unread,
Sep 30, 2009, 1:23:05 PM9/30/09
to android-platform
Are you saying that you are decrementing the drm count when the parser
is calling "UsageComplete" ? I am not a DRM expert, but intuitively I
would imagine that you would decrement the internal count -before-
giving out decrypted data...not at the end of playback.

-Ravi
> ...
>
> read more »

Hyeong-Ho Yoo

unread,
Sep 30, 2009, 8:50:44 PM9/30/09
to android-...@googlegroups.com

I mean the parser node calls iCPM->UsageComplete().
(You can see it in pvmf_mp3ffparser_node.cpp)
iCPM->UsageComplete calls my cpm plugin's UsageComplete and I can do proper job like decrementing drm count or whatever.
That's ok when I use MediaPlayer but the problem is it is also called when I use MediaMetadataRetriever.
What shall I do...? Should I not use MediaMetadataRetriever?
Any suggestion is welcome.



2009/10/1 RaviY <yen...@pv.com>

RaviY

unread,
Sep 30, 2009, 11:32:00 PM9/30/09
to android-platform
I think your logic of decrementing license count as part of
UsageComplete is not ideal. License count should be tied to
"AuthorizeUsage" (i.e., at the beginning of playback before passing
out any decrypted data).

-Ravi

On Sep 30, 5:50 pm, Hyeong-Ho Yoo <noranb...@gmail.com> wrote:
> I mean the parser node calls iCPM->UsageComplete().
> (You can see it in pvmf_mp3ffparser_node.cpp)
> iCPM->UsageComplete calls my cpm plugin's UsageComplete and I can do proper
> job like decrementing drm count or whatever.
> That's ok when I use MediaPlayer but the problem is it is also called when I
> use MediaMetadataRetriever.
> What shall I do...? Should I not use MediaMetadataRetriever?
> Any suggestion is welcome.
>
> 2009/10/1 RaviY <yend...@pv.com>
> ...
>
> read more »

swsuh

unread,
Oct 1, 2009, 8:31:39 AM10/1/09
to android-platform
An irrelevant question.
Why not publish MediaMetadataRetriever in SDK by default?
Is there any limitation or restriction?
For example, I cannot use MediaMetadataRetriever to retrieve the
metadata of midi file.
Are there other file type not supported?

Thanks for you answer.
> ...
>
> 閱讀更多 »

Freepine

unread,
Oct 1, 2009, 9:59:39 AM10/1/09
to android-...@googlegroups.com
But it would still decrement the license count when retrieving metadata in this way?
Will it make sense to add a new intent type in cpm_types.h to indicate that the client is intending to retrieve metadata only? As this kind of info is already passed to parser nodes in datasource's context data.

Freepine

unread,
Oct 1, 2009, 10:08:25 AM10/1/09
to android-...@googlegroups.com
Currently MediaMetadataRetriever only works for OpenCORE player engine. So midi and ogg files are not supported:)

RaviY

unread,
Oct 1, 2009, 2:43:15 PM10/1/09
to android-platform
No. It need not decrement the license. What you should be doing is
inside AuthorizeUsage implementation, you would check the "intent". If
the application sets the intent to
"BITMASK_PVMF_SOURCE_INTENT_GETMETADATA", you can look at this intent,
and fail AuthorizeUsage. And, inside the parser node, we will not
treat failure of "AuthorizeUsage" as fatal for a "metadata" intent.

-Ravi

On Oct 1, 6:59 am, Freepine <freep...@gmail.com> wrote:
> But it would still decrement the license count when retrieving metadata in
> this way?Will it make sense to add a new intent type in cpm_types.h to
> indicate that the client is intending to retrieve metadata only? As this
> kind of info is already passed to parser nodes in datasource's context data.
>
> ...
>
> read more »

Hyeong-Ho Yoo

unread,
Oct 2, 2009, 5:23:03 AM10/2/09
to android-...@googlegroups.com
Yes. MetadataDriver sets the intent to BITMASK_PVMF_SOURCE_INTENT_GETMETADATA
but this intent goes only to FrameMetadataUtil and Player Engine doesn't get this, neither does cpm.
so cpm plugin never knows this intent.

AFAIK, MediaMetadataRetriever.setDataSource() and MediaPlayer.prepare() both go through cpm plugin's AuthorizeUsage() ~ cpm plugin's UsageComplete() with same intent.
How can cpm plugins know they are called byMediaMetadataRetriever or MediaPlayer?

One more thing, the purpose of cpm plugin's UsageComplete() is decrementing count.
Check out doc/pv_cpm_developers_guide.pdf  2.1.7.
The doc says "The idea is to inform the DRM agent that the previously authorized usage is complete so the
DRM agent can update information such as usage counts."

I really appreciate RaviY, Hedge, Freepine's replies.

2009/10/2 RaviY <yen...@pv.com>

RaviY

unread,
Oct 2, 2009, 10:23:22 AM10/2/09
to android-platform


On Oct 2, 4:23 am, Hyeong-Ho Yoo <noranb...@gmail.com> wrote:
> Yes. MetadataDriver sets the intent to
> BITMASK_PVMF_SOURCE_INTENT_GETMETADATA
> but this intent goes only to FrameMetadataUtil and Player Engine doesn't get
> this, neither does cpm.
> so cpm plugin never knows this intent.
This shouldn't be the case. The CPM will receive the intent as part of
source context data.
>
> AFAIK, MediaMetadataRetriever.setDataSource() and MediaPlayer.prepare() both
> go through cpm plugin's AuthorizeUsage() ~ cpm plugin's UsageComplete() with
> same intent.
> How can cpm plugins know they are called byMediaMetadataRetriever or
> MediaPlayer?
The cpm plugin will differentiate based only upon the source intent.
>
> One more thing, the purpose of cpm plugin's UsageComplete() is decrementing
> count.
> Check out doc/pv_cpm_developers_guide.pdf  2.1.7.
> The doc says "The idea is to inform the DRM agent that the previously
> authorized usage is complete so the
> DRM agent can update information such as usage counts."
Oh ok. I guess I did not read that. But, as a CPM plugin provider, I
would rather decrement the count before giving out any decrypted data
than hoping that the user would call some "API" that would decrement
the count. I can confirm this. In either case, AuthorizeUsage() or
UsageComplete() will be called only once. So, you would not be
decrementing the drm count if you look at the source "intent".
>
> I really appreciate RaviY, Hedge, Freepine's replies.
>
> 2009/10/2 RaviY <yend...@pv.com>
> ...
>
> read more »

Freepine

unread,
Oct 2, 2009, 10:38:39 AM10/2/09
to android-...@googlegroups.com
Thanks. So are you implying that CPM plugin should still decrypt the content for retrieving metadata even though it returns failure in AuthorizeUsage? say, for OMA v1 content?

Hyeong-Ho Yoo

unread,
Oct 2, 2009, 11:56:16 PM10/2/09
to android-...@googlegroups.com
I looked at the source again and you are right. The intent packed in PVMFLocalDataSource goes through CPM.
But sadly...  it is only true for mp4, amr, aac nodes.
mp3 node doesn't deliver intent value, only filehandle.
If this is not intended, should be fixed in the next release.
(It seems to me mp4, amr, aac nodes are made by one developer and mp3 node made by another.
 I remember in OpenCORE 2.04, only mp3 node didn't work correctly with cpm.)

I agree with the where to decrement count. DRM providers did want to decrement count before playback start like you said.
I just haven't thought AuthorizeUsage as the place for doing the job.

Now I can use MediaMetadataRetriever for showing drm info before playback. Thank you very much.

I still have one question left though. Actually this has made me uncomfortable since the beginning.
As Freepine asked, why is MediaMetadataRetriever class ("such-a-beautiful-api") non-public?
Is it only because capture frame is not done?
Or is there any other reason it shouldn't be used directly?

2009/10/2 RaviY <yen...@pv.com>

Hedge

unread,
Oct 3, 2009, 12:46:55 PM10/3/09
to android-platform
Yes, you really ought to decrement use counts before UsageComplete.
Otherwise it is entirely too easy to get around the use count limit
(just rip out the battery before you're done playing).

It can be inconvenient for MediaMetadataRetriever to get all the
metadata items at once. You have to ensure that there are no side-
effects for any metadata retrieval method in your DRM scheme.

However, you can prevent UsageComplete from being called if you call
MediaMetadataRetriever.setMode with MODE_GET_METADATA_ONLY first.
Give that a try and see if it helps you out.
> ...
>
> read more »

RaviY

unread,
Oct 3, 2009, 8:13:22 PM10/3/09
to android-platform
Yes. If you (the CPM plugin) want to provide any metadata pertaining
to the actual DRM content, you would have to retrieve it from the
content. Again, it depends on the actual CPM plugin because some DRM
agents allow to retrieve metadata without any actual decryption.

-Ravi

On Oct 2, 9:38 am, Freepine <freep...@gmail.com> wrote:
> Thanks. So are you implying that CPM plugin should still decrypt the content
> for retrieving metadata even though it returns failure in AuthorizeUsage?
> say, for OMA v1 content?
>
> ...
>
> read more »

RaviY

unread,
Oct 3, 2009, 8:16:38 PM10/3/09
to android-platform


On Oct 2, 10:56 pm, Hyeong-Ho Yoo <noranb...@gmail.com> wrote:
> I looked at the source again and you are right. The intent packed in
> PVMFLocalDataSource goes through CPM.
> But sadly...  it is only true for mp4, amr, aac nodes.
> mp3 node doesn't deliver intent value, only filehandle.
> If this is not intended, should be fixed in the next release.
> (It seems to me mp4, amr, aac nodes are made by one developer and mp3 node
> made by another.
>  I remember in OpenCORE 2.04, only mp3 node didn't work correctly with cpm.)
I did not look at the code in detail, but if there is an issue, I will
file a bug internally to get the behavior on mp3 straightened out.

>
> I agree with the where to decrement count. DRM providers did want to
> decrement count before playback start like you said.
> I just haven't thought AuthorizeUsage as the place for doing the job.
>
> Now I can use MediaMetadataRetriever for showing drm info before playback.
> Thank you very much.
>
> I still have one question left though. Actually this has made me
> uncomfortable since the beginning.
> As Freepine asked, why is MediaMetadataRetriever class
> ("such-a-beautiful-api") non-public?
> Is it only because capture frame is not done?
> Or is there any other reason it shouldn't be used directly?
I am not aware of the reason, but will try to find out.
>
> 2009/10/2 RaviY <yend...@pv.com>
> ...
>
> read more »

RaviY

unread,
Oct 3, 2009, 8:21:13 PM10/3/09
to android-platform


On Oct 3, 11:46 am, Hedge <awoo...@gmail.com> wrote:
> Yes, you really ought to decrement use counts before UsageComplete.
> Otherwise it is entirely too easy to get around the use count limit
> (just rip out the battery before you're done playing).
>
> It can be inconvenient for MediaMetadataRetriever to get all the
> metadata items at once.  You have to ensure that there are no side-
> effects for any metadata retrieval method in your DRM scheme.
>
> However, you can prevent UsageComplete from being called if you call
> MediaMetadataRetriever.setMode with MODE_GET_METADATA_ONLY first.
> Give that a try and see if it helps you out.
I am not sure about that. UsageComplete() will be called whenever Reset
() is called.
> ...
>
> read more »

Freepine

unread,
Oct 4, 2009, 10:14:04 AM10/4/09
to android-...@googlegroups.com
On Sat, Oct 3, 2009 at 11:56 AM, Hyeong-Ho Yoo <nora...@gmail.com> wrote:
As Freepine asked, why is MediaMetadataRetriever class ("such-a-beautiful-api") non-public?
Is it only because capture frame is not done?
Or is there any other reason it shouldn't be used directly?

I don't remember I've asked that:) But usually a non-public class is subject to change. Maybe someday google will change its definition or replace it with other interfaces, e.g, adding metadata related APIs in MediaPlayer.java directly... 
Besides, applications can obtain most of the metadatas from media provider already.

Freepine

unread,
Oct 4, 2009, 10:28:50 AM10/4/09
to android-...@googlegroups.com
On Sun, Oct 4, 2009 at 8:21 AM, RaviY <yen...@pv.com> wrote:



On Oct 3, 11:46 am, Hedge <awoo...@gmail.com> wrote:
> Yes, you really ought to decrement use counts before UsageComplete.
> Otherwise it is entirely too easy to get around the use count limit
> (just rip out the battery before you're done playing).
>
> It can be inconvenient for MediaMetadataRetriever to get all the
> metadata items at once.  You have to ensure that there are no side-
> effects for any metadata retrieval method in your DRM scheme.
>
> However, you can prevent UsageComplete from being called if you call
> MediaMetadataRetriever.setMode with MODE_GET_METADATA_ONLY first.
> Give that a try and see if it helps you out.
I am not sure about that. UsageComplete() will be called whenever Reset
() is called.
I agree. And if you are referring AMR/AAC files, then it's probably a known bug in the corresponding parser nodes. You can change iFileHandle in DoReset to iAMRParser and iAACParser respectively .

1123     if (iFileHandle != NULL)
1124     {
1125         /* Indicates that the init was successfull */
1126         if ((iCPM))
1127         {
1128             SendUsageComplete();
1129         }

RaviY

unread,
Oct 4, 2009, 12:45:41 PM10/4/09
to android-platform
Yes. I remember we fixed this recently.

-Ravi

On Oct 4, 9:28 am, Freepine <freep...@gmail.com> wrote:
> On Sun, Oct 4, 2009 at 8:21 AM, RaviY <yend...@pv.com> wrote:
>
> > On Oct 3, 11:46 am, Hedge <awoo...@gmail.com> wrote:
> > > Yes, you really ought to decrement use counts before UsageComplete.
> > > Otherwise it is entirely too easy to get around the use count limit
> > > (just rip out the battery before you're done playing).
>
> > > It can be inconvenient for MediaMetadataRetriever to get all the
> > > metadata items at once.  You have to ensure that there are no side-
> > > effects for any metadata retrieval method in your DRM scheme.
>
> > > However, you can prevent UsageComplete from being called if you call
> > > MediaMetadataRetriever.setMode with MODE_GET_METADATA_ONLY first.
> > > Give that a try and see if it helps you out.
> > I am not sure about that. UsageComplete() will be called whenever Reset
> > () is called.
>
> I agree. And if you are referring AMR/AAC files, then it's probably a known
> bug in the corresponding parser nodes. You can change iFileHandle in DoReset
> to iAMRParser and iAACParser respectively .
>
> 1123<http://android.git.kernel.org/?p=platform/external/opencore.git;a=blo...>
>    if (iFileHandle != NULL)
> 1124<http://android.git.kernel.org/?p=platform/external/opencore.git;a=blo...>
>    {
> 1125<http://android.git.kernel.org/?p=platform/external/opencore.git;a=blo...>
>        /* Indicates that the init was successfull */
> 1126<http://android.git.kernel.org/?p=platform/external/opencore.git;a=blo...>
>        if ((iCPM))
> 1127<http://android.git.kernel.org/?p=platform/external/opencore.git;a=blo...>
>        {
> 1128<http://android.git.kernel.org/?p=platform/external/opencore.git;a=blo...>
>            SendUsageComplete();
> 1129<http://android.git.kernel.org/?p=platform/external/opencore.git;a=blo...>
>        }

NoraBora

unread,
Oct 7, 2009, 7:27:25 AM10/7/09
to android-platform
I'm still working on this issue.
Using MediaMetadataRetriever solves almost everything.

Today I found something new.
CPM Plugin's ReleaseNodeMetadataValues() is not called.
Engine calls parser node's ReleaseNodeMetadataValues().
parser node's ReleaseNodeMetadataValues() deletes only parser node's
metadata values.
It never calls CPM Plugin's ReleaseNodeMetadataValues().

For this reason, I can't add character type metadata value to my cpm
plugin.

Does anybody know about this?

RaviY

unread,
Oct 7, 2009, 3:07:32 PM10/7/09
to android-platform
It is a bug. I will get this taken care of.

-Ravi

RaviY

unread,
Oct 7, 2009, 8:24:39 PM10/7/09
to android-platform
I confirmed this. We recommend decrementing any drm count as part of
AuthorizeUsage(). I will be updating the cpm developer's guide with
the same.

-Ravi
> ...
>
> read more »

Hyeong-Ho Yoo

unread,
Oct 7, 2009, 8:32:54 PM10/7/09
to android-...@googlegroups.com
Thank you for your reply.

Another report here.(more like suggestion)

I think it would be better if android/metadatadriver.cpp includes "pvmi_drm_kvp.h".
so MetadataDriver::METADATA_KEYS could use drm metadata query like PVMF_DRM_INFO_LICENSE_COUNT_QUERY, PVMF_DRM_INFO_LICENSE_EXPIRATION_TIME_QUERY...

Have a good day...maybe night there.

2009/10/8 RaviY <yen...@pv.com>

RaviY

unread,
Oct 7, 2009, 8:46:15 PM10/7/09
to android-platform
What we need is a way to extend the mediascanner/metadataretriever
without making modifications to the defaults. I did not think about it
a whole lot to suggest a feasible solution. Any suggestions are
welcome.

-Ravi

On Oct 7, 7:32 pm, Hyeong-Ho Yoo <noranb...@gmail.com> wrote:
> Thank you for your reply.
>
> Another report here.(more like suggestion)
>
> I think it would be better if android/metadatadriver.cpp includes
> "pvmi_drm_kvp.h".
> so MetadataDriver::METADATA_KEYS could use drm metadata query like
> PVMF_DRM_INFO_LICENSE_COUNT_QUERY,
> PVMF_DRM_INFO_LICENSE_EXPIRATION_TIME_QUERY...
>
> Have a good day...maybe night there.
>
> 2009/10/8 RaviY <yend...@pv.com>

Atish

unread,
Oct 14, 2009, 12:49:31 AM10/14/09
to android-platform
hi Ravi,

As u said
"I confirmed this. We recommend decrementing any drm count as part of
AuthorizeUsage()"

But this is being called from DoReset() of parser nodes.

SO what the media player app do not call Reset method(current music
app also does not call Reset)??

so how should rights be decremented??

"Push(iCPMContainer, PVMFSubNodeContainerBaseMp3::ECPMUsageComplete);"
where should we enque the ECPMUsageComplete command??

Regards,
Atish
> > > > Does anybody know about this?- Hide quoted text -
>
> - Show quoted text -

NoraBora

unread,
Oct 14, 2009, 3:37:49 AM10/14/09
to android-...@googlegroups.com
AuthorizeUsage() is called during MediaPlayer.prepare().

2009/10/14 Atish <atis...@gmail.com>

Atish

unread,
Oct 14, 2009, 9:11:33 AM10/14/09
to android-platform
As i explained the reason in the following link

http://groups.google.com/group/android-porting/browse_thread/thread/3884fb9eb7248862/4ab1edc7ae0b5014#4ab1edc7ae0b5014

Authorize Usuage won't help.
So what is ideal place to rights consumption??

On Oct 14, 12:37 pm, NoraBora <noranb...@gmail.com> wrote:
> AuthorizeUsage() is called during MediaPlayer.prepare().
>
> 2009/10/14 Atish <atish...@gmail.com>
> > > - Show quoted text -- Hide quoted text -

yasuyuki

unread,
Oct 26, 2009, 5:26:11 AM10/26/09
to android-platform
hi Ravi.

On 9月3日, 午前4:22, RaviY <yend...@pv.com> wrote:
> The documentation in section 4.2 does sound convoluted :). I shall
> check if I can get that updated. I confirm that the trust is between
> the "user" and the "CPM plugin".

Where is the latest documentation? I found rev.1 Nov 16,2008 only.

thanks.

--yasuyuki

NoraBora

unread,
Oct 26, 2009, 7:07:04 AM10/26/09
to android-platform
I'm working on cpm & metadata and it seems there is a bug.

MediaPlayer.GetDuration (which calls GetMetadataValues) is not working
with CPM Plugin.
I tested a normal mp3 file with oma1 passthru cpm plugin.

I think it is somewhere around MP3Parser::GetDuration() in fileformats/
mp3/parser/src/mp3parser.cpp.
GetDurationFromRandomScan() is not called if (!fp->GetCPM()) is true.
but even though I commented out the condition and
GetDurationFromRandomScan() is called,
the duration is not correct.

Any help?

On Oct 14, 10:11 pm, Atish <atish...@gmail.com> wrote:
> As i explained the reason in the following link
>
> http://groups.google.com/group/android-porting/browse_thread/thread/3...
> > > > > so MetadataDriver::METADATA_KEYS could use drmmetadataquery like
> > > > > PVMF_DRM_INFO_LICENSE_COUNT_QUERY,
> > > > > PVMF_DRM_INFO_LICENSE_EXPIRATION_TIME_QUERY...
>
> > > > > Have a good day...maybe night there.
>
> > > > > 2009/10/8 RaviY <yend...@pv.com>
>
> > > > > > It is a bug. I will get this taken care of.
>
> > > > > > -Ravi
>
> > > > > > On Oct 7, 6:27 am, NoraBora <noranb...@gmail.com> wrote:
> > > > > > > I'm still working on this issue.
> > > > > > > Using MediaMetadataRetriever solves almost everything.
>
> > > > > > > Today I found something new.
> > > > > > > CPM Plugin's ReleaseNodeMetadataValues() is not called.
> > > > > > > Engine calls parser node's ReleaseNodeMetadataValues().
> > > > > > > parser node's ReleaseNodeMetadataValues() deletes only parser
> > > node's
> > > > > > >metadatavalues.
> > > > > > > It never calls CPM Plugin's ReleaseNodeMetadataValues().
>
> > > > > > > For this reason, I can't add character typemetadatavalue to my

RaviY

unread,
Oct 26, 2009, 10:48:22 AM10/26/09
to android-platform
It isn't out yet.

-Ravi

RaviY

unread,
Oct 26, 2009, 10:49:29 AM10/26/09
to android-platform
We have a fix pending.

-Ravi

NoraBora

unread,
Nov 2, 2009, 8:31:11 PM11/2/09
to android-platform
To contribute(upload patch to gerrit),
do I have to print "Individual Contributor License Grant", fill the
form, scan it and email to cla-sub...@google.com?
or just fill the online form(address, country, phone...), type "I
AGREE" and click submit is enough?

On Oct 26, 11:49 pm, RaviY <yend...@pv.com> wrote:
> We have a fix pending.
>
> -Ravi
>
> On Oct 26, 6:07 am, NoraBora <noranb...@gmail.com> wrote:
>
> > I'm working on cpm &metadataand it seems there is a bug.

Freepine

unread,
Nov 10, 2009, 8:18:06 AM11/10/09
to android-...@googlegroups.com
Hi Ravi,

I noticed that the fix was pushed to the master branch. Will it be better to check the content type before invoking UsageComplete() as RequestUsage() isn't called for non-protected content? (as already did in MP3/MP4 source nodes.)

-Freepine

>        }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to android-platfo...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en
-~----------~----~----~----~------~----~------~--~---


RaviY

unread,
Nov 10, 2009, 9:33:50 AM11/10/09
to android-platform
I guess so. I will make the change to amr and aac parser nodes. Thanks
for pointing it out.

But, calling UsageComplete should not do any harm.

-Ravi

On Nov 10, 7:18 am, Freepine <freep...@gmail.com> wrote:
> Hi Ravi,
>
> I noticed that the fix was pushed to the master branch. Will it be better to
> check the content type before invoking UsageComplete() as RequestUsage()
> isn't called for non-protected content? (as already did in MP3/MP4 source
> nodes.)
>
> -Freepine
>
> > android-platfo...@googlegroups.com<android-platform%2Bunsu...@googlegroups.com>
Reply all
Reply to author
Forward
0 new messages