/***************************************************************************** * Import_M3U: main import function *****************************************************************************/ int Import_M3U( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; const uint8_t *p_peek; char *(*pf_dup) (const char *) = GuessEncoding; int offset = 0; CHECK_FILE(); if( vlc_stream_Peek( p_demux->s, &p_peek, 3 ) == 3 && !memcmp( p_peek, "\xef\xbb\xbf", 3) ) { pf_dup = CheckUnicode; /* UTF-8 Byte Order Mark */ offset = 3; } if( demux_IsPathExtension( p_demux, ".m3u8" ) || demux_IsForced( p_demux, "m3u8" ) || CheckContentType( p_demux->s, "application/vnd.apple.mpegurl" ) ) pf_dup = CheckUnicode; /* UTF-8 file type */ else if( demux_IsPathExtension( p_demux, ".m3u" ) || demux_IsPathExtension( p_demux, ".vlc" ) || demux_IsForced( p_demux, "m3u" ) || ContainsURL( p_demux ) || CheckContentType( p_demux->s, "audio/x-mpegurl") ) ; /* Guess encoding */ else { if( vlc_stream_Peek( p_demux->s, &p_peek, 8 + offset ) < (8 + offset) ) return VLC_EGENERIC; p_peek += offset; if( !strncasecmp( (const char *)p_peek, "RTSPtext", 8 ) ) /* QuickTime */ pf_dup = CheckUnicode; /* UTF-8 */ else if( !memcmp( p_peek, "#EXTM3U", 7 ) ) ; /* Guess encoding */ else return VLC_EGENERIC; } vlc_stream_Seek( p_demux->s, offset ); STANDARD_DEMUX_INIT_MSG( "found valid M3U playlist" ); p_demux->p_sys->psz_prefix = FindPrefix( p_demux ); p_demux->p_sys->pf_dup = pf_dup; return VLC_SUCCESS; }
int Import_ASX( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; if( demux_IsPathExtension( p_demux, ".asx" ) || demux_IsPathExtension( p_demux, ".wax" ) || demux_IsPathExtension( p_demux, ".wvx" ) || ( ( CheckContentType( p_demux->s, "video/x-ms-asf" ) || CheckContentType( p_demux->s, "audio/x-ms-wax" ) ) && PeekASX( p_demux ) ) || demux_IsForced( p_demux, "asx-open" ) ) { STANDARD_DEMUX_INIT_MSG( "found valid ASX playlist" ); return VLC_SUCCESS; } else return VLC_EGENERIC; }
int Import_ASX( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t *)p_this; CHECK_FILE(); if( demux_IsPathExtension( p_demux, ".asx" ) || demux_IsPathExtension( p_demux, ".wax" ) || demux_IsPathExtension( p_demux, ".wvx" ) || ( ( CheckContentType( p_demux->s, "video/x-ms-asf" ) || CheckContentType( p_demux->s, "audio/x-ms-wax" ) ) && PeekASX( p_demux ) ) || demux_IsForced( p_demux, "asx-open" ) ) { msg_Dbg( p_demux, "found valid ASX playlist" ); } else return VLC_EGENERIC; p_demux->pf_control = Control; p_demux->pf_demux = Demux; return VLC_SUCCESS; }
bool IsAACContentType(const nsAString& aContentType) { return CheckContentType(aContentType, [](const nsAString& type) { return type.EqualsLiteral("audio/mp4") || type.EqualsLiteral("audio/x-m4a"); }, [](const nsAString& codec) { return codec.EqualsLiteral("mp4a.40.2") || // MPEG4 AAC-LC codec.EqualsLiteral("mp4a.40.5") || // MPEG4 HE-AAC codec.EqualsLiteral("mp4a.67"); // MPEG2 AAC-LC }); }
bool IsH264ContentType(const nsAString& aContentType) { return CheckContentType(aContentType, [](const nsAString& type) { return type.EqualsLiteral("video/mp4"); }, [](const nsAString& codec) { int16_t profile = 0; int16_t level = 0; return ExtractH264CodecDetails(codec, profile, level); } ); }
// // Checks the specified request if it contains supported content type. // static BOOL IeCheckContentType( HANDLE hRequest ) { BOOL Ret = FALSE; ULONG bRead = 0; LPTSTR Content; HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_TYPE, NULL, &bRead, NULL); if (Content = hAlloc(bRead + sizeof(_TCHAR))) { if (HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_TYPE, Content, &bRead, NULL)) { Content[bRead] = 0; Ret = CheckContentType(Content); } hFree(Content); } // if (Content = hAlloc(bRead)) return(Ret); }
// // Searches for HTTP-headers within the specified context buffer. // Parses HTTP headers. // static VOID ContextParseHeaders( PPR_SOCKET Ps, PHANDLE_CONTEXT Ctx ) { HRESULT hResult; LPSTREAM pStream = Ctx->pStream; LPSTREAM pDataStream = Ctx->pReceiveStream; PHTTP_HEADERS Headers = NULL; ULONG SizeOfHeaders = 0; ASSERT(Ctx->cActive); ASSERT(Ctx->cActive == Ctx->cTotal); // Checking for HTTP reply headers, and avaliability of CRLF sequence // Currently only standard CRLF-devided headers are supported if (HttpIsReply(Ctx->cBuffer, Ctx->cTotal) && StrStrI(Ctx->cBuffer, szCRLF)) // Loading data until we have whole HTTP header read, or buffer is full, or any error occured. SizeOfHeaders = BlockingReadHeaders(Ps, Ctx, TRUE); ASSERT(SizeOfHeaders <= MAX_CONTENT_BUFFER_SIZE); // Check out HTTP headers: we assume we have enough space to completely receive all headers. if (SizeOfHeaders && (Headers = HttpParseHeaders(Ctx->cBuffer, SizeOfHeaders))) { PCHAR ContentType = HttpFindHeaderA(Headers->Binary, szContentType, NULL); Ctx->Flags = (Ctx->Flags & CF_REPLACE) | Headers->Flags; Ctx->Length = 0; // Check if the content should be completely replaced... if ((Ctx->Flags & CF_REPLACE) || // ... or check out the content type ((ContentType) && CheckContentType(ContentType))) { PCHAR nBuffer; ULONG nSize; Ctx->Flags |= CF_CONTENT; ASSERT(Headers->HeadersSize <= Ctx->cTotal); Ctx->cActive = (Ctx->cTotal - Headers->HeadersSize); // Clear main data stream StreamClear(Ctx->pStream); // Clear content load stream StreamClear(Ctx->pReceiveStream); // Clear content grab stream StreamClear(Ctx->pStream1); // Removing "Content-Security-Policy" header if (nBuffer = HttpSetHeaderA(Headers->Binary, szSecPolicy, NULL, NULL)) { hFree(Headers->Binary); Headers->Binary = nBuffer; } // Removing "X-Frame-Options" header if (nBuffer = HttpSetHeaderA(Headers->Binary, szXFrameOptions, NULL, NULL)) { hFree(Headers->Binary); Headers->Binary = nBuffer; } // Looking for "Access-Control-Allow-Origin" header if (StrStrI(Headers->Binary, szAccessCtrlOrigin)) { // Setting "Access-Control-Allow-Origin" value to "*" if (nBuffer = HttpSetHeaderA(Headers->Binary, szAccessCtrlOrigin, "*", NULL)) { hFree(Headers->Binary); Headers->Binary = nBuffer; } } // if (StrStrI(Headers->Binary, szAccessCtrlOrigin)) // Check out if the content is not chunked or the page should be completely replaced if (!(Ctx->Flags & CF_CHUNKED) || (Ctx->Flags & CF_REPLACE)) { ASSERT(!(Ctx->Flags & CF_CHUNKED) || !(Ctx->Flags & CF_LENGTH)); // Checking if the page content will be replaced if (Ctx->Flags & CF_REPLACE) { // Loading HTTP headers of the page to replace with if (GetReplaceHeaders(Ctx->tCtx, &nBuffer, &nSize) == NO_ERROR) { hFree(Headers->Binary); Headers->Binary = nBuffer; Headers->HeadersSize = nSize; } // if (GetReplaceHeaders(Ctx->tCtx, &nBuffer, &nSize) == NO_ERROR) Ctx->Flags &= ~(CF_CHUNKED | CF_LENGTH); Ctx->ChunkSize = 1; } // if (Ctx->Flags & CF_REPLACE) else { if (Ctx->Flags & CF_LENGTH) { // Content has specified length if ((Ctx->ChunkSize = Headers->ContentSize) == 0) // There's no HTTP content, nothing to process Ctx->Flags = 0; } else // There's no content length specified // Setting ChunkSize to indicate that we gonna continue loading data until the connection is closed. Ctx->ChunkSize = 1; } if (Ctx->Flags & CF_CONTENT) { // Setting "Transfer-encoding: chunked" header if (nBuffer = HttpSetHeaderA(Headers->Binary, szTransferEncoding, szChunked, NULL)) { hFree(Headers->Binary); Headers->Binary = nBuffer; } // Removing "Content-length" header if (nBuffer = HttpSetHeaderA(Headers->Binary, szContentLength, NULL, NULL)) { hFree(Headers->Binary); Headers->Binary = nBuffer; } // "Transfer-encoding: chunked" avaliable from HTTP version 1.1 only and version 1.0 will ignore it, // so we have to replace HTTP version in reply to support chunked. ASSERT(Headers->Binary[5] == '1' && Headers->Binary[6] == '.'); Headers->Binary[7] = '1'; } // if (Ctx->Flags & CF_CONTENT) } // if (Ctx->Flags & CF_LENGTH) else // Content has no length specified Ctx->ChunkSize = 0; #if _DEBUG if (Ctx->pHeaders = hAlloc(Headers->HeadersSize + 1)) { memcpy(Ctx->pHeaders, Headers->Binary, Headers->HeadersSize); Ctx->pHeaders[Headers->HeadersSize] = 0; } #endif // Writing HTTP headers to the main stream hResult = CoInvoke(pStream, Write, Headers->Binary, lstrlen(Headers->Binary), NULL); ASSERT(hResult == S_OK); StreamGotoBegin(pStream); } // if ((ContentType) && else // Reseting context flags. We not gonna process it. Ctx->Flags = 0; HttpReleaseHeaders(Headers); } // if (SizeOfHeaders && (Headers = HttpParseHeaders(Ctx->cBuffer, SizeOfHeaders))) }