本文整理汇总了C++中MediaScannerClient::handleStringTag方法的典型用法代码示例。如果您正苦于以下问题:C++ MediaScannerClient::handleStringTag方法的具体用法?C++ MediaScannerClient::handleStringTag怎么用?C++ MediaScannerClient::handleStringTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaScannerClient
的用法示例。
在下文中一共展示了MediaScannerClient::handleStringTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LOGD
static PVMFStatus parseMP3(const char *filename,MediaScannerClient& client) {
PVID3ParCom pvId3Param;
PVFile fileHandle;
Oscl_FileServer iFs;
uint32 duration;
//LOGD("c---> filename 好的 = %s", filename);
if (iFs.Connect() != 0) {
LOGD("=======iFs.Connect failed========>\n");
return PVMFFailure;
}
oscl_wchar output[MAX_BUFF_SIZE];
oscl_UTF8ToUnicode((const char *) filename, oscl_strlen((const char *) filename),
(oscl_wchar *) output, MAX_BUFF_SIZE);
if (0 !=
fileHandle.Open((oscl_wchar *) output, Oscl_File::MODE_READ | Oscl_File::MODE_BINARY,
iFs)) {
//LOGE("Could not open the input file for reading(Test: parse id3).\n");
return PVMFFailure;
}
fileHandle.Seek(0, Oscl_File::SEEKSET);
pvId3Param.ParseID3Tag(&fileHandle);
fileHandle.Close();
iFs.Close();
//Get the frames information from ID3 library
PvmiKvpSharedPtrVector framevector;
pvId3Param.GetID3Frames(framevector);
uint32 num_frames = framevector.size();
for (uint32 i = 0; i < num_frames; i++) {
const char *key = framevector[i]->key;
bool isUtf8 = false;
bool isIso88591 = false;
// type should follow first semicolon
const char *type = strchr(key, ';');
if (type == NULL) continue;
type++;
char tracknumkeybuf[100];
if (strncmp(key, "track-info/track-number;", 24) == 0) {
// Java expects the track number key to be called "tracknumber", so
// construct a temporary one here.
snprintf(tracknumkeybuf, sizeof(tracknumkeybuf), "tracknumber;%s", type);
key = tracknumkeybuf;
}
const char *value = framevector[i]->value.pChar_value;
// KVP_VALTYPE_UTF8_CHAR check must be first, since KVP_VALTYPE_ISO88591_CHAR
// is a substring of KVP_VALTYPE_UTF8_CHAR.
// Similarly, KVP_VALTYPE_UTF16BE_WCHAR must be checked before KVP_VALTYPE_UTF16_WCHAR
if (oscl_strncmp(type, KVP_VALTYPE_UTF8_CHAR, KVP_VALTYPE_UTF8_CHAR_LEN) == 0) {
isUtf8 = true;
} else if (
oscl_strncmp(type, KVP_VALTYPE_ISO88591_CHAR, KVP_VALTYPE_ISO88591_CHAR_LEN) ==
0) {
isIso88591 = true;
}
if (isUtf8) {
// validate to make sure it is legal utf8
uint32 valid_chars;
if (oscl_str_is_valid_utf8((const uint8 *) value, valid_chars)) {
// utf8 can be passed through directly
//LOGD("c---> key(utf8) = %s ; value = %s", key, value);
if (!client.handleStringTag(key, value)) goto failure;
} else {
// treat as ISO-8859-1 if UTF-8 fails
isIso88591 = true;
}
}
if (isIso88591) {
size_t iInLen = strlen(value);
char sOutBuf[100];
size_t iOutLen = 100;
memset(sOutBuf, 0x00, 100);
ChangeCode("GBK", "UTF-8", value, &iInLen, sOutBuf, &iOutLen);
//LOGD("c---> key(gbk) = %s ; value = %s", key, sOutBuf);
if (!client.handleStringTag(key, sOutBuf)) goto failure;
}
// treat it as iso-8859-1 and our native encoding detection will try to
// figure out what it is
/* if (isIso88591) {
// convert ISO-8859-1 to utf8, worse case is 2x inflation
const unsigned char *src = (const unsigned char *) value;
char *temp = (char *) alloca(strlen(value) * 2 + 1);
if (temp) {
char *dest = temp;
unsigned int uch;
while ((uch = *src++) != 0) {
if (uch & 0x80) {
*dest++ = (uch >> 6) | 0xc0;
*dest++ = (uch & 0x3f) | 0x80;
} else *dest++ = uch;
//.........这里部分代码省略.........
示例2: LOGE
static PVMFStatus parseMP3(const char *filename, MediaScannerClient& client)
{
PVID3ParCom pvId3Param;
PVFile fileHandle;
Oscl_FileServer iFs;
uint32 duration;
if (iFs.Connect() != 0)
{
LOGE("iFs.Connect failed\n");
return PVMFFailure;
}
oscl_wchar output[MAX_BUFF_SIZE];
oscl_UTF8ToUnicode((const char *)filename, oscl_strlen((const char *)filename), (oscl_wchar *)output, MAX_BUFF_SIZE);
if (0 != fileHandle.Open((oscl_wchar *)output, Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, iFs) )
{
LOGE("Could not open the input file for reading(Test: parse id3).\n");
return PVMFFailure;
}
fileHandle.Seek(0, Oscl_File::SEEKSET);
pvId3Param.ParseID3Tag(&fileHandle);
fileHandle.Close();
iFs.Close();
//Get the frames information from ID3 library
PvmiKvpSharedPtrVector framevector;
pvId3Param.GetID3Frames(framevector);
uint32 num_frames = framevector.size();
for (uint32 i = 0; i < num_frames;i++)
{
const char* key = framevector[i]->key;
bool validUtf8 = true;
// type should follow first semicolon
const char* type = strchr(key, ';') + 1;
if (type == 0) continue;
const char* value = framevector[i]->value.pChar_value;
// KVP_VALTYPE_UTF8_CHAR check must be first, since KVP_VALTYPE_ISO88591_CHAR
// is a substring of KVP_VALTYPE_UTF8_CHAR.
// Similarly, KVP_VALTYPE_UTF16BE_WCHAR must be checked before KVP_VALTYPE_UTF16_WCHAR
if (oscl_strncmp(type, KVP_VALTYPE_UTF8_CHAR, KVP_VALTYPE_UTF8_CHAR_LEN) == 0) {
// utf8 can be passed through directly
// but first validate to make sure it is legal utf8
uint32 valid_chars;
validUtf8 = oscl_str_is_valid_utf8((const uint8 *)value, valid_chars);
if (validUtf8 && !client.handleStringTag(key, value)) goto failure;
}
// if the value is not valid utf8, then we will treat it as iso-8859-1
// and our native encoding detection will try to figure out what it is
if (oscl_strncmp(type, KVP_VALTYPE_ISO88591_CHAR, KVP_VALTYPE_ISO88591_CHAR_LEN) == 0
|| !validUtf8) {
// iso-8859-1
// convert to utf8
// worse case is 2x inflation
const unsigned char* src = (const unsigned char *)value;
char* temp = (char *)alloca(strlen(value) * 2 + 1);
if (temp) {
char* dest = temp;
unsigned int uch;
while ((uch = *src++) != 0) {
if (uch & 0x80) {
*dest++ = (uch >> 6) | 0xc0;
*dest++ = (uch & 0x3f) | 0x80;
} else *dest++ = uch;
}
*dest = 0;
if (!client.addStringTag(key, temp)) goto failure;
}
} else if (oscl_strncmp(type, KVP_VALTYPE_UTF16BE_WCHAR, KVP_VALTYPE_UTF16BE_WCHAR_LEN) == 0 ||