ECode CTestBasicType::strCon( /* [in] */ String i, /* [in] */ String j, /* [out] */ String * pO) { // TODO: Add your code here StringBuf_<2> strBuf; strBuf.Append(i); strBuf.Append(j); // *pO = new String(strBuf); return NOERROR; }
ECode CVideoPlayer::GetSpecFromYouTubeVideoID( /* [in] */ const String& id, /* [out] */ String* spec) { ECode ec; AutoPtr<IInputStream> stream; AutoPtr<IInputStreamReader> streamReader; AutoPtr<IBufferedReader> br; StringBuf_<6144> sb; String line; AutoPtr<IUri> fakeUri; String stream_map; AutoPtr<ArrayOf<String> > values; Int32 index = 0, count; String info_uri("http://www.youtube.com/get_video_info?&video_id="); info_uri += id; AutoPtr<IURL> info_url; ASSERT_SUCCEEDED(CURL::New(info_uri, (IURL**)&info_url)); AutoPtr<IURLConnection> urlConnection; ec = info_url->OpenConnection((IURLConnection**)&urlConnection); if (FAILED(ec)) { goto exception;} ec = urlConnection->GetInputStream((IInputStream**)&streamReader); if (FAILED(ec)) { goto exception;} ASSERT_SUCCEEDED(CInputStreamReader::New(stream, (IInputStreamReader**)&streamReader)); ASSERT_SUCCEEDED(CBufferedReader::New(streamReader,(IBufferedReader**)&br)); br->ReadLine(&line); while (line != NULL) { sb.Append(line); ec = br->ReadLine(&line); if (FAILED(ec)) { goto exception;} } // ec = Uri::Parse(String("fake:/fake?") + sb.GetPayload(), (IUri**)&fakeUri); // if (FAILED(ec)) { goto exception;} assert(0); /* ec = fakeUri->GetQueryParameter("url_encoded_fmt_stream_map", &stream_map); if (FAILED(ec)) { goto exception;}*/ if (stream_map == NULL) { *spec = NULL; return NOERROR; } StringUtils::Split(stream_map, String(","), (ArrayOf<String>**)&values); count = values ? values->GetLength() : 0; for (index = 0; index < count; ++i) { String st = (*values)[i]; // ec = Uri::Parse(String("fake:/fake?") + st, (IUri**)&fakeUri); // if (FAILED(ec)) { goto exception;} String url; assert(0); /* ec = fakeUri->GetQueryParameter("url", &url); if (FAILED(ec)) { goto exception;}*/ String type; assert(0); /* ec = fakeUri->GetQueryParameter("type", &type); if (FAILED(ec)) { goto exception;}*/ if (type != NULL && url != NULL && (type.StartWith("video/mp4") || type.StartWith("video/webm"))) { *spec = url; } } return NOERROR; exception: printf("VideoPlayer" "exception"); return NOERROR; }