About obscurity of some extended attributes structures descr
WMPTalk.com Forum Index WMPTalk.com
Discuss Windows Media Player
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web wmptalk.com
About obscurity of some extended attributes structures descr
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    WMPTalk.com Forum Index -> SDK
Author Message
Vincas Stepankevicius
Guest





Posted: Mon Oct 04, 2004 2:52 pm    Post subject: About obscurity of some extended attributes structures descr Reply with quote

Hi all,
I wonder if anybody have tried to read/write WM file (wma,mp3) extended
attributes, such as WM/Lyrics_Synchronised or WM/Picture.
I tried to do this in VB.NET (many thanks to Robert Smith for help), using
WMFSDKWrapper.dll from WMFSDK, and had no problems, reading/writing simple
WM attributes of type
WMT_ATTR_DATATYPE.WMT_TYPE_STRING, .WMT_TYPE_DWORD, .WMT_TYPE_QWORD or
..WMT_TYPE_BOOL.
I'm even able to read all extended attributes, and show their values
(embeded pictures, lyrics and synchronised lyrics).
But here I'm running into problems, raised by some mismatch between
structures described in WMFSDK and those returned by
IWMHeaderInfo3.GetAttributeByIndexEx
Let's take attribute "WM/Lyrics_Synchronised".
WMFSDK states that it's data array must contain such structure:

typedef struct _WMSynchronisedLyrics{
BYTE bTimeStampFormat; '(1 or 2 - depending on TimeStamp
format used)
BYTE bContentType; '(0-8 - ContentType dependant)
LPWSTR pwszContentDescriptor; '(Pointer to a wide-character
null-terminated string containing data from the encoding application;
app-dependant(?))
DWORD dwLyricsLen; '(length of the lyrics data in bytes)
BYTE* pbLyrics; '(Pointer to a BYTE array
containing the lyrics)
} WM_SYNCHRONISED_LYRICS;

, while dataArray, returned by GetAttributeByIndexEx, contains this (by zero
based position in array):

0(1-st byte) - bTimeStampFormat (2 in my case, meaning absolute time of the
lyric in milliseconds)
1(2-nd byte) - bContentType (1 in my case, meaning song lyrics)
2(3-6 bytes) - dword, with unknown meaning, let's name it dwA
6(7-10 bytes) - dword, corresponding to dwLyricsLen
10(11-14 bytes) - dword, with unknown meaning, let's name it dwB
14 - wide-character null-terminated string, containing description of
Synched lyrics attribute,
and after it goes pbLyrics-BYTE array containing the lyrics data (timestamps
& their strings) itself.

The most interesting thing is that dwords dwA and dwB are getting new,
absolutely random at first sight values on every GetAttributeByIndexEx call
on the same mp3 file!
I say 'at first sight' because it's not absolutely true: difference dwB-dwA
always remains the same for a file (but may differ for various files)!
It would be only interesting, if I only wanted to read synched lyrics - I
can simply ignore those dwA & dwB; and I do so, reading
WM/Lyrics_Synchronised.
But when you decide to update this attribute, you'll see, that you can't
ignore them, leaving zeroed or even filling with some values according this
strange 'constant difference' rule!
That's why I ask for your help. Of course, it would be ideal to see some VB
code sample for updating (IWMHeaderInfo3.ModifyAttribute), but I thank in
advance for any ideas in vb.net or c#:)

Here is the same mismatch for WM/Picture for example:
description in WMFSDK:

typedef struct _WMPicture{
LPWSTR pwszMIMEType;
BYTE bPictureType;
LPWSTR pwszDescription;
DWORD dwDataLen;
BYTE* pbData;
} WM_PICTURE;

structure, returned by GetAttributeByIndexEx:
0: - dword with unknown meaning
4: - bPictureType (Picture type (author, album cover, group etc.) )
5: - dword with unknown meaning
9: - dwDataLen 'Picture size
13: -dword with unknown meaning
17: -pwszMIMEType (wide-character null-terminated string, usualy
"image/jpeg" in my case)
then goes pwszDescription,
then goes pbData

So, please, all guru, - help me to find a vb.net solution for WM attributes
update!

tia,
Vincas Stepankevicius

P.S.
One idea came into my head while writing these notes - most likely those
'mystic' dwords means nothing else but addresses of pointers to data?
Nonetheless I don't know what can I do with such 'knowledge', - so you
remain my last hope :)

Back to top
smith
Guest





Posted: Tue Oct 05, 2004 2:29 am    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

I'll give a $10 prize (ten dollars US) via Paypal to anyone who can answer
this adequately using VB.Net or C# (without using UnSafe).

Code to this group please, Vincas being the judge of the result.

Robert Smith
Kirkland, WA
http://www.smithvoice.com

"Vincas Stepankevicius" <vstepankevicius@vilnius.vmi.lt> wrote in message
news:e6pTwAgqEHA.3520@TK2MSFTNGP11.phx.gbl...
Back to top
smith
Guest





Posted: Tue Oct 05, 2004 2:33 am    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

Make that "The First Person" with the adequate answer, judged by Vincas :)

-smith

"smith" <rcsTAKEOUT@smithvoiceTAKEOUT.com> wrote in message
news:C9k8d.2693$UP1.2180@newsread1.news.pas.earthlink.net...
Quote:
I'll give a $10 prize (ten dollars US) via Paypal to anyone who can answer
this adequately using VB.Net or C# (without using UnSafe).

Code to this group please, Vincas being the judge of the result.

Robert Smith
Kirkland, WA
http://www.smithvoice.com

"Vincas Stepankevicius" <vstepankevicius@vilnius.vmi.lt> wrote in message
news:e6pTwAgqEHA.3520@TK2MSFTNGP11.phx.gbl...



Back to top
Neil Smith [MVP Digital M
Guest





Posted: Tue Oct 05, 2004 12:18 pm    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

I'll consider giving $10 to anybody who understands and can explain to
me a word he's on about Hehe. ;-)))

Cheers - Neil

On Mon, 04 Oct 2004 22:29:54 GMT, "smith"
<rcsTAKEOUT@smithvoiceTAKEOUT.com> wrote:

Quote:
I'll give a $10 prize (ten dollars US) via Paypal to anyone who can answer
this adequately using VB.Net or C# (without using UnSafe).

Code to this group please, Vincas being the judge of the result.

Robert Smith
Kirkland, WA
http://www.smithvoice.com

"Vincas Stepankevicius" <vstepankevicius@vilnius.vmi.lt> wrote in message
news:e6pTwAgqEHA.3520@TK2MSFTNGP11.phx.gbl...
Back to top
Vincas Stepankevicius
Guest





Posted: Tue Oct 05, 2004 2:03 pm    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

Hi, Neil,

Of cource, you may be not so savy as I expected, but please be at least more
well-meant :)
If my terrible English (I'm Lithanian) is the only reason you can't answer
this question - it's not so bad ;)

In the simplest terms I just asked for a sample of VB.NET code for updating
extended binary attributes of media files...
If you are still hazy about purport of my request - please, be so kind -
don't waste your time :)

thanks,
Vincas


"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:o2n4m056oedn8v3bsausukcbtdngg5pe75@4ax.com...
Quote:
I'll consider giving $10 to anybody who understands and can explain to
me a word he's on about Hehe. ;-)))

Cheers - Neil

On Mon, 04 Oct 2004 22:29:54 GMT, "smith"
rcsTAKEOUT@smithvoiceTAKEOUT.com> wrote:

I'll give a $10 prize (ten dollars US) via Paypal to anyone who can
answer
this adequately using VB.Net or C# (without using UnSafe).

Code to this group please, Vincas being the judge of the result.

Robert Smith
Kirkland, WA
http://www.smithvoice.com

"Vincas Stepankevicius" <vstepankevicius@vilnius.vmi.lt> wrote in message
news:e6pTwAgqEHA.3520@TK2MSFTNGP11.phx.gbl...

Back to top
Alessandro Angeli [MVP::D
Guest





Posted: Tue Oct 05, 2004 2:09 pm    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

"Vincas Stepankevicius" <vstepankevicius@vilnius.vmi.lt> wrote:

Quote:
One idea came into my head while writing these notes - most likely
those 'mystic' dwords means nothing else but addresses of pointers to
data? Nonetheless I don't know what can I do with such 'knowledge', -
so you remain my last hope :)

They are pointers and the difference is a constant because the data is
always laid out in th same way. You can access the data they point to using
methods in System.Runtime.InteropServices.Marshal like PtrToStringUni(),
PtrToStructure(), ReadByte(), ReadInt16()... I think there may be a more
elegant solution, but this should do.


--

Alessandro Angeli

MVP::DigitalMedia

a dot angeli at biosys dot net
Back to top
Alessandro Angeli [MVP::D
Guest





Posted: Tue Oct 05, 2004 2:11 pm    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

"Alessandro Angeli [MVP::DigitalMedia]" <nobody@nowhere.in.the.net> wrote:

Quote:
They are pointers and the difference is a constant because the data is
always laid out in th same way. You can access the data they point to
using methods in System.Runtime.InteropServices.Marshal like
PtrToStringUni(), PtrToStructure(), ReadByte(), ReadInt16()... I
think there may be a more elegant solution, but this should do.

Of course, you can use the inverse methods to write new data and get
pointers to your own structs and strings.


--

Alessandro Angeli

MVP::DigitalMedia

a dot angeli at biosys dot net
Back to top
Iain
Guest





Posted: Tue Oct 05, 2004 2:55 pm    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

Allesandro's comments are pertinent here.

It is also useful to know that the Lyrics fields are derived from the MP3
definitions for such things which are documented in in various places.

I haven't looked at them in detail so the following may be wrong.

It *may* be that in practive the pointers are effectively offsets into the
datablock so if you tread them as longs and see what is at point it may be
pertinent.

Iain
Back to top
Vincas Stepankevicius
Guest





Posted: Tue Oct 05, 2004 2:58 pm    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

Thanx, Alessandro,
I'll try it, while one question still remains: which structure must be used
in IWMHeaderInfo3.ModifyAttribute - structure described in SDK or one
returned by GetAttributeByIndexEx? They are different even considering your
explanation.

I'm glad to see that my English is not such bad as to be absolutely unclear
:)

thanks,
Vincas

Alessandro Angeli [MVP::DigitalMedia]" <nobody@nowhere.in.the.net> wrote in
message news:O%23pfpNsqEHA.1644@tk2msftngp13.phx.gbl...
Quote:
"Vincas Stepankevicius" <vstepankevicius@vilnius.vmi.lt> wrote:

One idea came into my head while writing these notes - most likely
those 'mystic' dwords means nothing else but addresses of pointers to
data? Nonetheless I don't know what can I do with such 'knowledge', -
so you remain my last hope :)

They are pointers and the difference is a constant because the data is
always laid out in th same way. You can access the data they point to
using
methods in System.Runtime.InteropServices.Marshal like PtrToStringUni(),
PtrToStructure(), ReadByte(), ReadInt16()... I think there may be a more
elegant solution, but this should do.


--

Alessandro Angeli

MVP::DigitalMedia

a dot angeli at biosys dot net
Back to top
Alessandro Angeli [MVP::D
Guest





Posted: Tue Oct 05, 2004 3:23 pm    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

"Iain" <IainXXX@idcl.co.uk> wrote:

Quote:
It *may* be that in practive the pointers are effectively offsets
into the datablock so if you tread them as longs and see what is at
point it may be pertinent.

I don't think so. The data block where the pointers are embedded is
marshalled as an unstructured byte array so they are not interpreted and
hence must retain their valued in unmanaged code, where they are actual
pointers and not offsets.


--

Alessandro Angeli

MVP::DigitalMedia

a dot angeli at biosys dot net
Back to top
Alessandro Angeli [MVP::D
Guest





Posted: Tue Oct 05, 2004 3:45 pm    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

"Vincas Stepankevicius" <vstepankevicius@vilnius.vmi.lt> wrote:

Quote:
I'll try it, while one question still remains: which structure must
be used in IWMHeaderInfo3.ModifyAttribute - structure described in
SDK or one returned by GetAttributeByIndexEx? They are different even
considering your explanation.

Both methods do not use any specific structure so I'll assume you mean the
structure relative to a specific attribute type, for example
WM_SYNCHRONISED_LYRICS, in which case the structure is exactly the same for
both methods, no difference. Or maybe you meant that the buffer you get
filled by GetAttributeByIndexEx() doesn't look like a WM_SYNCHRONISED_LYRICS
structure? Since I do not have any file that contains such an attribute, I
can not investigate it (do you have a sample you can share?).


--

Alessandro Angeli

MVP::DigitalMedia

a dot angeli at biosys dot net
Back to top
Iain
Guest





Posted: Tue Oct 05, 2004 5:05 pm    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

On Tue, 5 Oct 2004 13:23:17 +0200, Alessandro Angeli [MVP::DigitalMedia]
wrote:

Quote:
"Iain" <IainXXX@idcl.co.uk> wrote:

It *may* be that in practive the pointers are effectively offsets
into the datablock so if you tread them as longs and see what is at
point it may be pertinent.

I don't think so. The data block where the pointers are embedded is
marshalled as an unstructured byte array so they are not interpreted and
hence must retain their valued in unmanaged code, where they are actual
pointers and not offsets.

Yeah, but are you saying that the the WMFSDK knows enough to fix up these
pointers as it loads the header metadata block into memory?

It would seem a remarkably clever thing to get it to do.

Mind you if you actually have tried this then I'll shut up, since I have
not. I found out just enough to reckon it wasn't worth my while! A little
knowledge and all that!

Iain
Back to top
Vincas Stepankevicius
Guest





Posted: Tue Oct 05, 2004 6:39 pm    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

"Alessandro Angeli [MVP::DigitalMedia]" <nobody@nowhere.in.the.net> wrote in
message news:e9wRWDtqEHA.3288@TK2MSFTNGP12.phx.gbl...
.......
Quote:
Both methods do not use any specific structure so I'll assume you mean the
structure relative to a specific attribute type, for example
WM_SYNCHRONISED_LYRICS, in which case the structure is exactly the same
for
both methods, no difference. Or maybe you meant that the buffer you get
filled by GetAttributeByIndexEx() doesn't look like a
WM_SYNCHRONISED_LYRICS
structure?

I agree, that *internal* structure is the same for both methods, but as you
can see from declaration of WMFSDKWrapper.dll method GetAttributeByIndexEx
inVB:
--
Public Overridable Function GetAttributeByIndexEx(ByVal wStreamNum As
System.UInt16,
ByVal wIndex As System.UInt16, ByVal pwszName As String, ByRef pwNameLen
As System.UInt16,
ByRef pType As WMFSDKWrapper.WMT_ATTR_DATATYPE, ByRef pwLangIndex As
System.UInt16, ByVal pValue() As Byte,
ByRef pdwDataLength As System.UInt32) As System.UInt32
--
, this method returns attribute data as as byte array pValue, and I must
decide myself what structure has data in it, depending on attr name &
type...

Quote:
Since I do not have any file that contains such an attribute, I
can not investigate it (do you have a sample you can share?).

Of cource I have, but I don't know if this group is a proper place for
messages with audio files attached :)
If You have Windows Media player (ver 9 or 10), you can simply create such
attributes on any mp3 or wma file you have.
If not - let me know, and I'll try to make a mp3 or wma file as little as
possible, with required attributes set.
If I got it right, I can use your spelled e-mail for sending such file.
Correct me if I'm wrong.

Vincas
Back to top
Vincas Stepankevicius
Guest





Posted: Tue Oct 05, 2004 6:45 pm    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

"Iain" <IainXXX@idcl.co.uk> wrote in message
news:1mtsmts0y3d6g.33wz6q9lcbg1.dlg@40tude.net...
Quote:
Allesandro's comments are pertinent here.

It is also useful to know that the Lyrics fields are derived from the MP3
definitions for such things which are documented in in various places.

I haven't looked at them in detail so the following may be wrong.

It *may* be that in practive the pointers are effectively offsets into the
datablock so if you tread them as longs and see what is at point it may be
pertinent.

Iain

Alessandro is positively right: they are *not* offsets in datablock for one
simple reason: their values are just too big for that :)

Vincas
Back to top
Neil Smith [MVP Digital M
Guest





Posted: Tue Oct 05, 2004 6:45 pm    Post subject: Re: About obscurity of some extended attributes structures d Reply with quote

Not at all - I wasn't being nasty ! I'm a web developer so I'm more or
less clueless about what you were asking ;-)

The English was fine, it was the technical content that baffled me.
It's probably a very interesting question, I just have no idea what
the answer will be !

Hopefully, Alessandro has a few clues he can offer.

Kind regards - Neil

On Tue, 5 Oct 2004 13:03:44 +0300, "Vincas Stepankevicius"
<vstepankevicius@vilnius.vmi.lt> wrote:

Quote:
Hi, Neil,

Of cource, you may be not so savy as I expected, but please be at least more
well-meant :)
If my terrible English (I'm Lithanian) is the only reason you can't answer
this question - it's not so bad ;)

In the simplest terms I just asked for a sample of VB.NET code for updating
extended binary attributes of media files...
If you are still hazy about purport of my request - please, be so kind -
don't waste your time :)

thanks,
Vincas


"Neil Smith [MVP Digital Media]" <neil@nospam.com> wrote in message
news:o2n4m056oedn8v3bsausukcbtdngg5pe75@4ax.com...
I'll consider giving $10 to anybody who understands and can explain to
me a word he's on about Hehe. ;-)))

Cheers - Neil

On Mon, 04 Oct 2004 22:29:54 GMT, "smith"
rcsTAKEOUT@smithvoiceTAKEOUT.com> wrote:

I'll give a $10 prize (ten dollars US) via Paypal to anyone who can
answer
this adequately using VB.Net or C# (without using UnSafe).

Code to this group please, Vincas being the judge of the result.

Robert Smith
Kirkland, WA
http://www.smithvoice.com

"Vincas Stepankevicius" <vstepankevicius@vilnius.vmi.lt> wrote in message
news:e6pTwAgqEHA.3520@TK2MSFTNGP11.phx.gbl...


Back to top
 
Post new topic   Reply to topic    WMPTalk.com Forum Index -> SDK All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Microsoft Office Forum New Topics
Powered by phpBB