[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-datatype-cvs
Subject:    [Datatype-cvs] aac/fileformat aacff.cpp,1.36.8.9.2.8,1.36.8.9.2.9
From:       fashengli () helixcommunity ! org
Date:       2012-07-20 5:43:54
[Download RAW message or body]

Update of /cvsroot/datatype/aac/fileformat
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv7015

Modified Files:
      Tag: hxclient_3_6_1_atlas
	aacff.cpp 
Log Message:
答复: [datatype-dev] CR: change to fix bug 14196: Metadata][AAC] The title, artist \
and album cannot be displayed Qing Li
Sent:   Friday, July 20, 2012 10:34 AM
To:     Fasheng Li; DL-china-helix-client-custproj-dev; Xiaolu Zhao; Henry Xing
Dear Fasheng,
the logic looks good, but please remove the following parts:
@@ -1,5 +1,5 @@
 /* ***** BEGIN LICENSE BLOCK *****
- * Source last modified: $Id: smplfsys.cpp,v 1.46.2.2.8.8.4.1 2012/03/09 07:25:42 \
shuohuang Exp $ + * Source last modified: $Id: smplfsys.cpp,v 1.46.2.2.8.8.4.1 \
                2012-03-09 07:25:42 shuohuang Exp $
  *
  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
  *
@@ -1,5 +1,5 @@
 /* ***** BEGIN LICENSE BLOCK *****
- * Source last modified: $Id: smplfsys.h,v 1.17.2.1.38.2 2012/01/10 14:57:23 \
ching_li Exp $ + * Source last modified: $Id: smplfsys.h,v 1.17.2.1.38.2 2012-01-10 \
                14:57:23 ching_li Exp $
  *
  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
  *
@@ -1,5 +1,5 @@
 /* ***** BEGIN LICENSE BLOCK *****
- * Source last modified: $Id: hxfiles.h,v 1.16.2.1.16.3 2011/07/11 09:24:26 \
henryxing Exp $ + * Source last modified: $Id: hxfiles.h,v 1.16.2.1.16.3 2011-07-11 \
                09:24:26 henryxing Exp $
  *
  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
  *

Best Regards!
                           Li Qing
--
RealNetworks China, Beijing Office
Tel: 008601059542848
Fax: 008601085656477
Address: 18th Floor,Tower B,Pacific Century Place,2A GongTiBeiLu,Chaoyang \
District,Beijing, China Post Code: 100027
________________________________________
发件人: Fasheng Li
发送时间: 2012年7月19日 18:54
收件人: Qing Li; DL-china-helix-client-custproj-dev; Xiaolu Zhao; Henry Xing
主题: RE: [datatype-dev] CR: change to fix bug 14196: Metadata][AAC] The title, \
artist and album cannot be displayed

Hi Qing,

I have modified the aacff.cpp according to your comments.

Regarding HELIX_FEATURE_64_BIT_FILE_SUPPORT, as we discussed, I have defined a new \
interface IHXFileObjectSync which can handle seek and read synchronously, and \
IHXFileObject2 inherits from this new interface.

Please help to review it again.

Thanks,
Fasheng
________________________________________
From: Qing Li
Sent: Wednesday, July 11, 2012 6:19 PM
To: Qing Li; Fasheng Li; DL-china-helix-client-custproj-dev; Xiaolu Zhao; Henry Xing
Subject: 答复: [datatype-dev] CR: change to fix bug 14196: Metadata][AAC] The \
title, artist and album cannot be displayed

one more suggestion:
it looks the following source codes can be wrapped as a function:

+            HX_RELEASE(XXXX);
+            retVal = m_pCommonClassFactory->CreateInstance(CLSID_IHXBuffer, (void \
**)&XXXX); +            if (SUCCEEDED(retVal))
+            {
+                retVal = XXXX->Set(&pData[0], uItemLength+1);
+                if (SUCCEEDED(retVal))
+                {
+                    (XXXX->GetBuffer())[ XXXX->GetSize() - 1] = '\0';
+                }
+                else
+                {
+                    HX_RELEASE(XXXX);
+                    break;
+                }
+            }



Best Regards!
                           Li Qing
--
RealNetworks China, Beijing Office
Tel: 008601059542848
Fax: 008601085656477
Address: 18th Floor,Tower B,Pacific Century Place,2A GongTiBeiLu,Chaoyang \
District,Beijing, China Post Code: 100027
________________________________________
发件人: Qing Li
发送时间: 2012年7月11日 18:14
收件人: Fasheng Li; DL-china-helix-client-custproj-dev; Xiaolu Zhao; Henry Xing
主题: 答复: [datatype-dev] CR: change to fix bug 14196: Metadata][AAC] The title, \
artist and album cannot be displayed

Dear Fasheng,
you should check if the macro HELIX_FEATURE_64_BIT_FILE_SUPPORT is defined before use \
IHXFileObject2 interface, if not you should use IHXFileObject interface to access the \
file. The logics looks good.

Best Regards!
                           Li Qing
--
RealNetworks China, Beijing Office
Tel: 008601059542848
Fax: 008601085656477
Address: 18th Floor,Tower B,Pacific Century Place,2A GongTiBeiLu,Chaoyang \
District,Beijing, China Post Code: 100027
________________________________________
发件人: Fasheng Li
发送时间: 2012年7月11日 17:31
收件人: DL-china-helix-client-custproj-dev; Xiaolu Zhao; Henry Xing
主题: FW: [datatype-dev] CR: change to fix bug 14196: Metadata][AAC] The title, \
artist and album cannot be displayed

Hi Experts,

Could you please help to review this CR for a internal bug?

Thanks,
Fasheng

-----Original Message-----
From: datatype-dev-bounces@helixcommunity.org \
                [mailto:datatype-dev-bounces@helixcommunity.org] On Behalf Of Fasheng \
                Li
Sent: 2012年5月25日 15:38
To: datatype-dev@helixcommunity.org
Subject: [datatype-dev] CR: change to fix bug 14196: Metadata][AAC] The title, artist \
and album cannot be displayed

Modified by: fashengli@realnetworks.com<mailto:fashengli@realnetworks.com>
Date: 05/25/2012
Project: RealPlayer for Android Smartphones
BugID: 14196
BugURL: https://bugs.helixcommunity.org/show_bug.cgi?id=14196


Synopsis:     Change to fix bug 14196: Metadata][AAC] The title, artist and album \
cannot be displayed

Overview:  Similar with MP3 file, AAC file may use ID3 or APEv2 tag to contain \
                metadata information.
               Some aac files don't have ID3 tag in the head of file but have APEv2 \
                tag in the end of file.
               When Media framework requests to extract metadata, helix will try to \
                read tag in head. If no tag information; it will set metadata to \
                NULL.
               What we do is try to read tag in the end of file if no tag found in \
head.

               This new feature has been modularized so it could be applied to other \
file formats easily.

Files Added:    None

Files Modified:
datatype/aac/fileformat/aacff.cpp
datatype/aac/fileformat/pub/aacff.h


Image size and Heap Use impact(Client - Only): None

Platforms and Profiles Affected:
 -- Platform: android-4.0-arm-qsd_8x60
 -- Profile:    helix-client-android-full

Distribution Libraries Affected: None

Distribution library impact and planned action: None

Platforms and Profiles Build Verified:
 -- Platform: android-4.0-arm-qsd_8x60
 -- Profile:    helix-client-android-full

Platforms and Profiles Functionality Verified:
 -- Platform: android-4.0-arm-qsd_8x60
 -- Profile:    helix-client-android-full

Branch:  361krill

Copyright assignment: I am a RealNetworks employee or contractor.


Best Regards,
Fasheng Li


Index: aacff.cpp
===================================================================
RCS file: /cvsroot/datatype/aac/fileformat/aacff.cpp,v
retrieving revision 1.36.8.9.2.8
retrieving revision 1.36.8.9.2.9
diff -u -d -r1.36.8.9.2.8 -r1.36.8.9.2.9
--- aacff.cpp	3 May 2012 03:17:01 -0000	1.36.8.9.2.8
+++ aacff.cpp	20 Jul 2012 05:41:10 -0000	1.36.8.9.2.9
@@ -70,6 +70,7 @@
  *  Defines
  */
 #define AAC_HEADER_SIZE         10
+#define AAC_FOOTER_SIZE         32
 #define SIZE_META_DATA_ID1      128
 #define SEEK_TABLE_SIZE         700
 #define DELTA_DURATION          2000
@@ -137,6 +138,8 @@
     m_pAuthor(NULL),
     m_pAlbum(NULL),
     m_pTitle(NULL),
+    m_pComment(NULL),
+    m_pGenre(NULL),
     m_bFirstPacket(TRUE),
     m_bForceLiveStream(FALSE),
     m_bExpectingMetaData(TRUE),
@@ -386,6 +389,8 @@
     HX_RELEASE(m_pAuthor);
     HX_RELEASE(m_pAlbum);
     HX_RELEASE(m_pTitle);
+    HX_RELEASE(m_pComment);
+    HX_RELEASE(m_pGenre);
     HX_RELEASE(m_pFirstAACFrame);
     HX_RELEASE(m_pContext);
     HX_RELEASE(m_pCommonClassFactory);
@@ -544,6 +549,90 @@
     return retVal;
 }
 
+HX_RESULT CAACFileFormat::CheckFooterMetaData() 
+{
+    HX_RESULT retVal = HXR_OK;
+    IHXFileObjectSync* pFileObjectSync = NULL;
+    IHXBuffer *pBuffer = NULL;
+
+    retVal = m_pFileObject->QueryInterface(IID_IHXFileObjectSync, \
(void**)&pFileObjectSync);  +    if (!SUCCEEDED(retVal)) {
+        return retVal;
+    }
+
+    retVal = m_pCommonClassFactory->CreateInstance(IID_IHXBuffer, (void**)&pBuffer);
+    if (!SUCCEEDED(retVal)) {
+        HX_RELEASE(pFileObjectSync);
+        return retVal;
+    }
+
+    UINT32 uCurPos   = pFileObjectSync->GetFilePosition32();
+    UINT32 uFileSize = pFileObjectSync->GetFileSize32();
+    UINT32 uSeekLen  = uFileSize - AAC_FOOTER_SIZE;
+
+    // seek to the end of file and read AAC_FOOTER_SIZE bytes
+    retVal = pFileObjectSync->Seek(uSeekLen, FALSE, TRUE);
+    if (!SUCCEEDED(retVal)) {
+        HX_RELEASE(pFileObjectSync);
+        HX_RELEASE(pBuffer);
+        return retVal;
+    }
+
+    retVal = pBuffer->SetSize(AAC_FOOTER_SIZE);
+    if (!SUCCEEDED(retVal)) {
+        HX_RELEASE(pFileObjectSync);
+        HX_RELEASE(pBuffer);
+        return retVal;
+    }
+
+    retVal = pFileObjectSync->Read(pBuffer, (UINT32)AAC_FOOTER_SIZE);
+    if (!SUCCEEDED(retVal) || !pBuffer) {
+        HX_RELEASE(pFileObjectSync);
+        HX_RELEASE(pBuffer);
+        return retVal;
+    }
+
+    UINT32 uTagSize = GetFooterMetaDataSize(pBuffer->GetBuffer());
+    if (!uTagSize) {
+        HX_RELEASE(pFileObjectSync);
+        HX_RELEASE(pBuffer);
+        return retVal;
+    }
+
+    // seek again and read APEv2 tag
+    uSeekLen = uFileSize - uTagSize;
+    retVal = pFileObjectSync->Seek(uSeekLen, FALSE, TRUE);
+    if (!SUCCEEDED(retVal)) {
+        HX_RELEASE(pFileObjectSync);
+        HX_RELEASE(pBuffer);
+        return retVal;
+    }
+
+    retVal = pBuffer->SetSize(uTagSize);
+    if (!SUCCEEDED(retVal)) {
+        HX_RELEASE(pFileObjectSync);
+        HX_RELEASE(pBuffer);
+        return retVal;
+    }
+    
+    retVal = pFileObjectSync->Read(pBuffer, (UINT32)uTagSize);
+    if (!SUCCEEDED(retVal) || !pBuffer) {
+        HX_RELEASE(pFileObjectSync);
+        HX_RELEASE(pBuffer);
+        return retVal;
+    }
+
+    ProcessFooterMetaData(pBuffer);
+
+    // seek back to the head of file
+    retVal = pFileObjectSync->Seek(uCurPos, FALSE, TRUE);
+
+    HX_RELEASE(pFileObjectSync);
+    HX_RELEASE(pBuffer);
+
+    return retVal;
+}
+
 STDMETHODIMP CAACFileFormat::ReadDone(HX_RESULT status, IHXBuffer* pBuffer)
 {
     HX_RESULT     retVal         = HXR_OK;
@@ -644,6 +733,8 @@
             }
             else
             {
+                retVal = CheckFooterMetaData();
+
                 pFrameBuffer = pBuffer->GetBuffer();
                 memcpy((UCHAR *)m_pHeader, pFrameBuffer, pBuffer->GetSize());
                 retVal = FindFileType(pFrameBuffer);
@@ -1226,6 +1317,19 @@
     return ulMetaDataSize;
 }
 
+UINT32 CAACFileFormat::GetFooterMetaDataSize(UCHAR *pData)
+{
+    UINT32 ulMetaDataSize = 0;
+    const char apetagex[] = "APETAGEX";
+    if ( 0 == strncmp((const char*)pData, apetagex, sizeof(apetagex)-1) ) {
+        // skip the tag string and version part, 8+4 bytes
+        pData += 12;
+        ulMetaDataSize = pData[0] | pData[1] << 8 | pData[2] << 16 | pData[3] << 24; \
 +    }   
+
+    return ulMetaDataSize;
+}
+
 // XXX: For ID3v2.3 (and 2.4), GetID3FrameSize() will skip a byte, 
 //      so, pBuffer should point to the last char of the Frame ID!
 UINT32 CAACFileFormat::GetID3FrameSize(const UCHAR *pBuffer)
@@ -1531,6 +1635,95 @@
     return retVal;
 }
 
+HX_RESULT CAACFileFormat::SetBuffer(IHXBuffer* &pBuffer, UCHAR *pData, UINT32 \
uItemLength) +{
+    HX_RESULT retVal = HXR_OK;
+    HX_RELEASE(pBuffer);
+    retVal = m_pCommonClassFactory->CreateInstance(CLSID_IHXBuffer, (void \
**)&pBuffer); +    if (SUCCEEDED(retVal))
+    {
+        retVal = pBuffer->Set(pData, uItemLength);
+        if (SUCCEEDED(retVal))
+        {
+            (pBuffer->GetBuffer())[ pBuffer->GetSize() - 1] = '\0';
+        }
+        else
+        {
+            HX_RELEASE(pBuffer);
+        }
+    }
+    return retVal;
+}
+
+HX_RESULT CAACFileFormat::ProcessFooterMetaData(IHXBuffer* pBuffer)
+{
+    HX_RESULT retVal    = HXR_OK;
+    UCHAR* pData        = pBuffer->GetBuffer();
+    UINT32 ulSize       = pBuffer->GetSize();
+
+    // get the item number
+    UCHAR* pb = pData + ulSize - AAC_FOOTER_SIZE + 16;
+    UINT8 items = pb[0] | (pb[1] << 8) | (pb[2] << 16) | (pb[3] << 24);
+
+    char buf[6];
+    for (UINT8 t=0; t<items; ++t) {
+        UINT32 uItemLength = pData[0] | (pData[1] << 8) | (pData[2] << 16) | \
(pData[3] << 24); +        pData += 8;
+
+        // get the first five char of each field
+        strncpy(buf, pData, 6);
+        buf[5] = '\0';
+
+        // skip field part, come to value part
+        while (*pData++ != 0x00) ;
+
+        if ( 0 == strncasecmp(buf, "artis", 5) )
+        {
+            retVal = SetBuffer(m_pAuthor, &pData[0], uItemLength+1); 
+            if (!SUCCEEDED(retVal))
+            {
+                break;
+            }
+        }
+        else if ( 0 == strncasecmp(buf, "title", 5) )
+        {
+            retVal = SetBuffer(m_pTitle, &pData[0], uItemLength+1);
+            if (!SUCCEEDED(retVal))
+            {
+                break;
+            }
+        }
+        else if ( 0 == strncasecmp(buf, "album", 5) )
+        {
+            retVal = SetBuffer(m_pAlbum, &pData[0], uItemLength+1);
+            if (!SUCCEEDED(retVal))
+            {
+                break;
+            }
+        }
+        else if ( 0 == strncasecmp(buf, "comme", 5) )
+        {
+            retVal = SetBuffer(m_pComment, &pData[0], uItemLength+1);
+            if (!SUCCEEDED(retVal))
+            {
+                break;
+            }
+        }
+        else if ( 0 == strncasecmp(buf, "genre", 5) )
+        {
+            retVal = SetBuffer(m_pGenre, &pData[0], uItemLength+1);
+            if (!SUCCEEDED(retVal))
+            {
+                break;
+            }
+        }
+
+        pData += uItemLength;
+    }
+
+    return retVal;
+}
+
 HX_RESULT CAACFileFormat::CreateFileHeader()
 {
     HX_RESULT retVal = HXR_OK;
@@ -1553,6 +1746,14 @@
         {
             retVal = pHdr->SetPropertyBuffer("Abstract", m_pAlbum);
         }
+        if (SUCCEEDED(retVal) && m_pComment)
+        {
+            retVal = pHdr->SetPropertyBuffer("Comment", m_pComment);
+        }
+        if (SUCCEEDED(retVal) && m_pGenre)
+        {
+            retVal = pHdr->SetPropertyBuffer("Genre", m_pGenre);
+        }
         if (SUCCEEDED(retVal) && m_pCopyRight)
         {
             retVal = pHdr->SetPropertyBuffer("Copyright", m_pCopyRight);


_______________________________________________
Datatype-cvs mailing list
Datatype-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/datatype-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic