OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rename(const oscl_wchar *oldpath, const oscl_wchar *newpath) { char oldconvpathname[OSCL_IO_FILENAME_MAXLEN]; char newconvpathname[OSCL_IO_FILENAME_MAXLEN]; if (0 == oscl_UnicodeToUTF8(oldpath, oscl_strlen(oldpath), oldconvpathname, OSCL_IO_FILENAME_MAXLEN) || 0 == oscl_UnicodeToUTF8(newpath, oscl_strlen(newpath), newconvpathname, OSCL_IO_FILENAME_MAXLEN)) { return OSCL_FILEMGMT_E_PATH_TOO_LONG; } return oscl_rename(oldconvpathname, newconvpathname); }
void PV2WayUtil::FindTestRange(cmd_line* command_line, uint32 &aFirstTest, uint32 &aLastTest, int32 aTestLimit) { //default is to run all tests. aFirstTest = 0; if (aTestLimit == 0) { aLastTest = MAX_324_TEST; } else { aLastTest = aTestLimit; } int testArgument = 0; char *iTestArgStr1 = NULL; char *iTestArgStr2 = NULL; bool cmdline_iswchar = command_line->is_wchar(); //-test //if (iTestFound) OSCL_HeapString<OsclMemAllocator> argument = "-test"; if (FindCmdArg(command_line, argument, testArgument)) { // Convert to UTF8 if necessary if (cmdline_iswchar) { iTestArgStr1 = OSCL_ARRAY_NEW(char, 256); OSCL_TCHAR* cmd; command_line->get_arg(testArgument, cmd); if (cmd) { oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iTestArgStr1, 256); } iTestArgStr2 = OSCL_ARRAY_NEW(char, 256); command_line->get_arg(testArgument + 1, cmd); if (cmd) { oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iTestArgStr2, 256); } } else { command_line->get_arg(testArgument, iTestArgStr1); command_line->get_arg(testArgument + 1, iTestArgStr2); } //Pull out 2 integers... PV_atoi(iTestArgStr1, 'd', aFirstTest); PV_atoi(iTestArgStr2, 'd', aLastTest); }
void pff_eos_test::test() { int error = 0; char *filename = new char[iFilename.get_size() + 1]; if ((filename == NULL) || (oscl_UnicodeToUTF8(iFilename.get_cstr(), iFilename.get_size(), filename, iFilename.get_size() + 1) == 0)) { OSCL_LEAVE(-1); } fprintf(fileoutput, "Start pff eos test, num runs %d, audio eos %d, vidoe eos %d, proxy %d, file %s\n", iMaxRuns, iWaitForAudioEOS, iWaitForVideoEOS, iUseProxy, filename); delete filename; scheduler = OsclExecScheduler::Current(); this->AddToScheduler(); if (start_async_test()) { OSCL_TRY(error, scheduler->StartScheduler()); if (error != 0) { OSCL_LEAVE(error); } } destroy_sink_source(); this->RemoveFromScheduler(); }
int32 OsclNativeFile::Open(const oscl_wchar *filename, uint32 mode , const OsclNativeFileParams& params , Oscl_FileServer& fileserv) { iMode = mode; iOpenFileHandle = false; OSCL_UNUSED_ARG(fileserv); OSCL_UNUSED_ARG(params); char openmode[4]; OpenModeToString(mode, openmode); #ifdef _UNICODE oscl_wchar convopenmode[4]; if (0 == oscl_UTF8ToUnicode(openmode, oscl_strlen(openmode), convopenmode, 4)) { return -1; } if ((iFile = _wfopen(filename, convopenmode)) == NULL) { return -1; } #else //Convert to UTF8 char convfilename[OSCL_IO_FILENAME_MAXLEN]; if (0 == oscl_UnicodeToUTF8(filename, oscl_strlen(filename), convfilename, OSCL_IO_FILENAME_MAXLEN)) { return -1; } return OpenFileOrSharedFd(convfilename, openmode); #endif }
void pff_pause_disconnect_test::test() { int error = 0; char *filename = new char[iFilename.get_size() + 1]; if ((filename == NULL) || (oscl_UnicodeToUTF8(iFilename.get_cstr(), iFilename.get_size(), filename, iFilename.get_size() + 1) == 0)) { OSCL_LEAVE(-1); } fprintf(fileoutput, "Start play from file pause disconnect test, before add source %d, file %s\n", iUsePlayFileBeforeAddSource, filename); delete filename; scheduler = OsclExecScheduler::Current(); this->AddToScheduler(); if (start_async_test()) { OSCL_TRY(error, scheduler->StartScheduler()); if (error != 0) { OSCL_LEAVE(error); } } destroy_sink_source(); this->RemoveFromScheduler(); }
void FindLogLevel(cmd_line* command_line, int32& loglevel, FILE* aFile) { //default is verbose loglevel = PVLOGMSG_DEBUG; bool cmdline_iswchar = command_line->is_wchar(); int count = command_line->get_count(); // Search for the "-logerr"/"-logwarn" argument char *iSourceFind = NULL; if (cmdline_iswchar) { iSourceFind = new char[256]; } // Go through each argument for (int iTestSearch = 0; iTestSearch < count; iTestSearch++) { // Convert to UTF8 if necessary if (cmdline_iswchar) { OSCL_TCHAR* cmd = NULL; command_line->get_arg(iTestSearch, cmd); oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iSourceFind, 256); } else { iSourceFind = NULL; command_line->get_arg(iTestSearch, iSourceFind); } // Do the string compare if (oscl_strcmp(iSourceFind, "-help") == NULL) { fprintf(aFile, "Log level options. Default is debug level:\n"); fprintf(aFile, " -logerr\n"); fprintf(aFile, " Log at error level\n"); fprintf(aFile, " -logwarn\n"); fprintf(aFile, " Log at warning level\n\n"); } else if (oscl_strcmp(iSourceFind, "-logerr") == NULL) { loglevel = PVLOGMSG_ERR; } else if (oscl_strcmp(iSourceFind, "-logwarn") == NULL) { loglevel = PVLOGMSG_WARNING; } } if (cmdline_iswchar) { delete[] iSourceFind; iSourceFind = NULL; } }
OSCL_EXPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_chdir(const oscl_wchar *path) { char convpathname[OSCL_IO_FILENAME_MAXLEN]; if (0 == oscl_UnicodeToUTF8(path, oscl_strlen(path), convpathname, OSCL_IO_FILENAME_MAXLEN) && oscl_strlen(path) != 0) { return OSCL_FILEMGMT_E_PATH_TOO_LONG; } return oscl_chdir(convpathname); }
OSCL_EXPORT_REF int32 Oscl_FileServer::Oscl_DeleteFile(const oscl_wchar* filename) { { //Convert to UTF8 char convfilename[OSCL_IO_FILENAME_MAXLEN]; if (0 == oscl_UnicodeToUTF8(filename, oscl_strlen(filename), convfilename, OSCL_IO_FILENAME_MAXLEN)) return (-1); return unlink(convfilename); } }
void FindMemMgmtRelatedCmdLineParams(cmd_line* command_line, bool& aPrintDetailedMemLeakInfo, FILE* aFile) { aPrintDetailedMemLeakInfo = false; bool cmdline_iswchar = command_line->is_wchar(); int count = command_line->get_count(); // Search for the "-logerr"/"-logwarn" argument char *iSourceFind = NULL; if (cmdline_iswchar) { iSourceFind = new char[256]; } // Go through each argument for (int iTestSearch = 0; iTestSearch < count; iTestSearch++) { // Convert to UTF8 if necessary if (cmdline_iswchar) { OSCL_TCHAR* cmd = NULL; command_line->get_arg(iTestSearch, cmd); oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iSourceFind, 256); } else { iSourceFind = NULL; command_line->get_arg(iTestSearch, iSourceFind); } // Do the string compare if (oscl_strcmp(iSourceFind, "-help") == NULL) { fprintf(aFile, "Printing leak info option. Default is OFF:\n"); fprintf(aFile, " -leakinfo\n"); fprintf(aFile, " If there is a memory leak, prints out the memory leak information\n"); fprintf(aFile, " after all specified test cases have finished running.\n\n"); } else if (oscl_strcmp(iSourceFind, "-leakinfo") == NULL) { aPrintDetailedMemLeakInfo = true; } } if (cmdline_iswchar) { delete[] iSourceFind; iSourceFind = NULL; } }
////// INetURI implementation //////////////////////////////////////////////////////////////////////////////////// bool INetURI::setURI(OSCL_wString &aUri, const bool aRedirectURI) { if (aUri.get_size() == 0) return false; OsclMemAllocator alloc; char *buf = (char*)alloc.allocate(aUri.get_size() + 1); if (!buf) return false; uint32 size = oscl_UnicodeToUTF8(aUri.get_cstr(), aUri.get_size(), buf, aUri.get_size() + 1); if (size == 0) { alloc.deallocate(buf); return false; } iURI = OSCL_HeapString<OsclMemAllocator> (buf, size); alloc.deallocate(buf); // clear iHost iHostName.set(NULL, 0); iRedirectURI = aRedirectURI; return true; }
void pv_metadata_engine_test::PrintSupportedMetaDataKeys() { uint32 i = 0; fprintf(file, "\n\nOutput for file: %s\n", iFileName); fprintf(file, "\nMetadata key list (count=%d):\n", iMetadataKeyList.size()); for (i = 0; i < iMetadataKeyList.size(); ++i) { fprintf(file, "Key %d: %s\n", (i + 1), iMetadataKeyList[i].get_cstr()); } fprintf(file, "\nMetadata value list (count=%d):\n", iMetadataValueList.size()); for (i = 0; i < iMetadataValueList.size(); ++i) { fprintf(file, "Value %d:\n Key string: %s\n", (i + 1), iMetadataValueList[i].key); switch (GetValTypeFromKeyString(iMetadataValueList[i].key)) { case PVMI_KVPVALTYPE_CHARPTR: fprintf(file, " Value:%s\n", iMetadataValueList[i].value.pChar_value); break; case PVMI_KVPVALTYPE_WCHARPTR: { // Assume string is in UCS-2 encoding so convert to UTF-8 char tmpstr[65]; oscl_UnicodeToUTF8(iMetadataValueList[i].value.pWChar_value, oscl_strlen(iMetadataValueList[i].value.pWChar_value), tmpstr, 65); tmpstr[64] = '\0'; fprintf(file, " Value(in UTF-8, first 64 chars):%s\n", tmpstr); } break; case PVMI_KVPVALTYPE_UINT32: fprintf(file, " Value:%d\n", iMetadataValueList[i].value.uint32_value); break; case PVMI_KVPVALTYPE_INT32: fprintf(file, " Value:%d\n", iMetadataValueList[i].value.int32_value); break; case PVMI_KVPVALTYPE_UINT8: fprintf(file, " Value:%d\n", iMetadataValueList[i].value.uint8_value); break; case PVMI_KVPVALTYPE_FLOAT: fprintf(file, " Value:%f\n", iMetadataValueList[i].value.float_value); break; case PVMI_KVPVALTYPE_DOUBLE: fprintf(file, " Value:%f\n", iMetadataValueList[i].value.double_value); break; case PVMI_KVPVALTYPE_BOOL: if (iMetadataValueList[i].value.bool_value) { fprintf(file, " Value:true(1)\n"); } else { fprintf(file, " Value:false(0)\n"); } break; default: fprintf(file, " Value: UNKNOWN VALUE TYPE\n"); break; } fprintf(file, " Length:%d Capacity:%d\n", iMetadataValueList[i].length, iMetadataValueList[i].capacity); } }
//Find test range args: //To run a range of tests by enum ID: // -test 17 29 void FindTestRange(cmd_line* command_line, int32& iFirstTest, int32 &iLastTest, FILE* aFile) { //default is to run all tests. iFirstTest = 0; iLastTest = 999; int iTestArgument = 0; char *iTestArgStr1 = NULL; char *iTestArgStr2 = NULL; bool iTestFound = false; bool cmdline_iswchar = command_line->is_wchar(); int count = command_line->get_count(); // Search for the "-test" argument char *iSourceFind = NULL; if (cmdline_iswchar) { iSourceFind = new char[256]; } // Go through each argument for (int iTestSearch = 0; iTestSearch < count; iTestSearch++) { // Convert to UTF8 if necessary if (cmdline_iswchar) { OSCL_TCHAR* cmd = NULL; command_line->get_arg(iTestSearch, cmd); oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iSourceFind, 256); } else { iSourceFind = NULL; command_line->get_arg(iTestSearch, iSourceFind); } // Do the string compare if (oscl_strcmp(iSourceFind, "-help") == NULL) { fprintf(aFile, "Test cases to run option. Default is ALL:\n"); fprintf(aFile, " -test x y\n"); fprintf(aFile, " Specify a range of test cases to run. To run one test case, use the\n"); fprintf(aFile, " same index for x and y.\n\n"); } else if (oscl_strcmp(iSourceFind, "-test") == NULL) { iTestFound = true; iTestArgument = ++iTestSearch; break; } } if (cmdline_iswchar) { delete[] iSourceFind; iSourceFind = NULL; } if (iTestFound) { // Convert to UTF8 if necessary if (cmdline_iswchar) { iTestArgStr1 = new char[256]; OSCL_TCHAR* cmd; command_line->get_arg(iTestArgument, cmd); if (cmd) { oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iTestArgStr1, 256); } iTestArgStr2 = new char[256]; command_line->get_arg(iTestArgument + 1, cmd); if (cmd) { oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), iTestArgStr2, 256); } } else { command_line->get_arg(iTestArgument, iTestArgStr1); command_line->get_arg(iTestArgument + 1, iTestArgStr2); } //Pull out 2 integers... if (iTestArgStr1 && '0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9' && iTestArgStr2 && '0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9') { int len = oscl_strlen(iTestArgStr1); switch (len) { case 3: iFirstTest = 0; if ('0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9') { iFirstTest = iFirstTest + 100 * (iTestArgStr1[0] - '0'); } if ('0' <= iTestArgStr1[1] && iTestArgStr1[1] <= '9') { iFirstTest = iFirstTest + 10 * (iTestArgStr1[1] - '0'); } if ('0' <= iTestArgStr1[2] && iTestArgStr1[2] <= '9') { iFirstTest = iFirstTest + 1 * (iTestArgStr1[2] - '0'); } break; case 2: iFirstTest = 0; if ('0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9') { iFirstTest = iFirstTest + 10 * (iTestArgStr1[0] - '0'); } if ('0' <= iTestArgStr1[1] && iTestArgStr1[1] <= '9') { iFirstTest = iFirstTest + 1 * (iTestArgStr1[1] - '0'); } break; case 1: iFirstTest = 0; if ('0' <= iTestArgStr1[0] && iTestArgStr1[0] <= '9') { iFirstTest = iFirstTest + 1 * (iTestArgStr1[0] - '0'); } break; default: break; } len = oscl_strlen(iTestArgStr2); switch (len) { case 3: iLastTest = 0; if ('0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9') { iLastTest = iLastTest + 100 * (iTestArgStr2[0] - '0'); } if ('0' <= iTestArgStr2[1] && iTestArgStr2[1] <= '9') { iLastTest = iLastTest + 10 * (iTestArgStr2[1] - '0'); } if ('0' <= iTestArgStr2[2] && iTestArgStr2[2] <= '9') { iLastTest = iLastTest + 1 * (iTestArgStr2[2] - '0'); } break; case 2: iLastTest = 0; if ('0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9') { iLastTest = iLastTest + 10 * (iTestArgStr2[0] - '0'); } if ('0' <= iTestArgStr2[1] && iTestArgStr2[1] <= '9') { iLastTest = iLastTest + 1 * (iTestArgStr2[1] - '0'); } break; case 1: iLastTest = 0; if ('0' <= iTestArgStr2[0] && iTestArgStr2[0] <= '9') { iLastTest = iLastTest + 1 * (iTestArgStr2[0] - '0'); } break; default: break; } } } if (cmdline_iswchar) { if (iTestArgStr1) { delete[] iTestArgStr1; iTestArgStr1 = NULL; } if (iTestArgStr2) { delete[] iTestArgStr2; iTestArgStr2 = NULL; } if (iSourceFind) { delete[] iSourceFind; iSourceFind = NULL; } } }
// Pull out source file name from arguments // -source sometestfile.mp4 // // void FindSourceFile(cmd_line* command_line, OSCL_HeapString<OsclMemAllocator>& aFileNameInfo, PVMFFormatType& aInputFileFormatType, FILE* aFile) { aFileNameInfo = SOURCENAME_PREPEND_STRING; aFileNameInfo += DEFAULTSOURCEFILENAME; aInputFileFormatType = DEFAULTSOURCEFORMATTYPE; int iFileArgument = 0; bool iFileFound = false; bool cmdline_iswchar = command_line->is_wchar(); int count = command_line->get_count(); // Search for the "-source" argument // Go through each argument for (int iFileSearch = 0; iFileSearch < count; iFileSearch++) { char argstr[128]; // Convert to UTF8 if necessary if (cmdline_iswchar) { oscl_wchar* argwstr = NULL; command_line->get_arg(iFileSearch, argwstr); oscl_UnicodeToUTF8(argwstr, oscl_strlen(argwstr), argstr, 128); argstr[127] = NULL; } else { char* tmpstr = NULL; command_line->get_arg(iFileSearch, tmpstr); int32 tmpstrlen = oscl_strlen(tmpstr) + 1; if (tmpstrlen > 128) { tmpstrlen = 128; } oscl_strncpy(argstr, tmpstr, tmpstrlen); argstr[tmpstrlen-1] = NULL; } // Do the string compare if (oscl_strcmp(argstr, "-help") == NULL) { fprintf(aFile, "Source specification option. Default is 'test.mp4':\n"); fprintf(aFile, " -source sourcename\n"); fprintf(aFile, " Specify the source filename or URL to use for test cases which\n"); fprintf(aFile, " allow user-specified source name. The unit test determines the\n"); fprintf(aFile, " source format type using extension or URL header.\n\n"); } else if (oscl_strcmp(argstr, "-source") == NULL) { iFileFound = true; iFileArgument = ++iFileSearch; break; } } if (iFileFound) { // Convert to UTF8 if necessary if (cmdline_iswchar) { oscl_wchar* cmd; command_line->get_arg(iFileArgument, cmd); char tmpstr[256]; oscl_UnicodeToUTF8(cmd, oscl_strlen(cmd), tmpstr, 256); tmpstr[255] = NULL; aFileNameInfo = tmpstr; } else { char* cmdlinefilename = NULL; command_line->get_arg(iFileArgument, cmdlinefilename); aFileNameInfo = cmdlinefilename; } // Check the file extension to determine format type // AAC file if (oscl_strstr(aFileNameInfo.get_cstr(), ".aac") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".AAC") != NULL) { aInputFileFormatType = PVMF_MIME_AACFF; } // MP3 file else if (oscl_strstr(aFileNameInfo.get_cstr(), ".mp3") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".MP3") != NULL) { aInputFileFormatType = PVMF_MIME_MP3FF; } // AMR file (IETF and IF2) else if (oscl_strstr(aFileNameInfo.get_cstr(), ".amr") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".AMR") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".cod") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".COD") != NULL) { aInputFileFormatType = PVMF_MIME_AMRFF; } // RTSP URL else if ((!oscl_strncmp("rtsp", aFileNameInfo.get_cstr(), 4)) || (!oscl_strncmp("RTSP", aFileNameInfo.get_cstr(), 4))) { aInputFileFormatType = PVMF_MIME_DATA_SOURCE_RTSP_URL; } // HTTP URL else if (oscl_strstr(aFileNameInfo.get_cstr(), "http:") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), "HTTP:") != NULL) { aInputFileFormatType = PVMF_MIME_DATA_SOURCE_HTTP_URL; } // MP4/3GP file else if (oscl_strstr(aFileNameInfo.get_cstr(), ".mp4") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".MP4") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".3gp") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".3GP") != NULL) { aInputFileFormatType = PVMF_MIME_MPEG4FF; } // ASF file else if (oscl_strstr(aFileNameInfo.get_cstr(), ".asf") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".ASF") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".wma") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".WMA") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".wmv") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".WMV") != NULL) { aInputFileFormatType = PVMF_MIME_ASFFF; } // SDP file else if (oscl_strstr(aFileNameInfo.get_cstr(), ".sdp") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".SDP") != NULL) { aInputFileFormatType = PVMF_MIME_DATA_SOURCE_SDP_FILE; } // PVX file else if (oscl_strstr(aFileNameInfo.get_cstr(), ".pvx") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".PVX") != NULL) { aInputFileFormatType = PVMF_MIME_DATA_SOURCE_PVX_FILE; } // WAV file else if (oscl_strstr(aFileNameInfo.get_cstr(), ".wav") != NULL || oscl_strstr(aFileNameInfo.get_cstr(), ".WAV") != NULL) { aInputFileFormatType = PVMF_MIME_WAVFF; } // Unknown so set to unknown and let the player engine determine the format type else { fprintf(file, "Source type unknown so setting to unknown and have the utility recognize it\n"); aInputFileFormatType = PVMF_MIME_FORMAT_UNKNOWN; } } }
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; } *dest = 0; LOGD("c---> key(iso) = %s ; value = %s", key, temp); //if (!client.addStringTag(key, temp)) goto failure; } }*/ // not UTF-8 or ISO-8859-1, try wide char formats if (!isUtf8 && !isIso88591 && (oscl_strncmp(type, KVP_VALTYPE_UTF16BE_WCHAR, KVP_VALTYPE_UTF16BE_WCHAR_LEN) == 0 || oscl_strncmp(type, KVP_VALTYPE_UTF16_WCHAR, KVP_VALTYPE_UTF16_WCHAR_LEN) == 0)) { // convert wchar to utf8 // the id3parcom library has already taken care of byteswapping const oscl_wchar *src = framevector[i]->value.pWChar_value; int srcLen = oscl_strlen(src); // worse case is 3 bytes per character, plus zero termination int destLen = srcLen * 3 + 1; char *dest = (char *) alloca(destLen); if (oscl_UnicodeToUTF8(src, oscl_strlen(src), dest, destLen) > 0) { //LOGD("c---> key(!utf8 && !iso) = %s ; value = %s", key, dest); if (!client.handleStringTag(key, dest)) goto failure; } } else if (oscl_strncmp(type, KVP_VALTYPE_UINT32, KVP_VALTYPE_UINT32_LEN) == 0) { char temp[20]; snprintf(temp, sizeof(temp), "%d", (int) framevector[i]->value.uint32_value); //LOGD("c---> key() = %s ; value = %s", key, temp); if (!client.handleStringTag(key, temp)) goto failure; } else { //LOGE("unknown tag type %s for key %s\n", type, key); } } // extract non-ID3 properties below { OSCL_wHeapString<OsclMemAllocator> mp3filename(output); MP3ErrorType err; IMpeg3File mp3File(mp3filename, err); if (err != MP3_SUCCESS) { //LOGE("IMpeg3File constructor returned %d for %s\n", err, filename); return err; } err = mp3File.ParseMp3File(); if (err != MP3_SUCCESS) { //LOGE("IMpeg3File::ParseMp3File returned %d for %s\n", err, filename); return err; } char buffer[20]; duration = mp3File.GetDuration(); sprintf(buffer, "%d", duration); LOGD("c---> duration = %s", "duration"); //if (!client.addStringTag("duration", buffer)) goto failure; } return PVMFSuccess; failure: return PVMFFailure; }