Go to Google Groups Home    microsoft.public.windowsmedia.sdk
About obscurity of some extended attributes structures descriptions given in WMFSDK

Vincas Stepankevicius <vstepankevic...@vilnius.vmi.lt>

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 :)