michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set sw=2 ts=8 et tw=80 : */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "RtspChannelChild.h" michael@0: #include "RtspChannelParent.h" michael@0: #include "RtspHandler.h" michael@0: #include "nsILoadGroup.h" michael@0: #include "nsIInterfaceRequestor.h" michael@0: #include "nsIURI.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsStandardURL.h" michael@0: #include "mozilla/net/NeckoChild.h" michael@0: michael@0: namespace mozilla { michael@0: namespace net { michael@0: michael@0: NS_IMPL_ISUPPORTS(RtspHandler, nsIProtocolHandler) michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: // RtspHandler::nsIProtocolHandler michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: NS_IMETHODIMP michael@0: RtspHandler::GetScheme(nsACString &aScheme) michael@0: { michael@0: aScheme.AssignLiteral("rtsp"); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: RtspHandler::GetDefaultPort(int32_t *aDefaultPort) michael@0: { michael@0: *aDefaultPort = kDefaultRtspPort; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: RtspHandler::GetProtocolFlags(uint32_t *aProtocolFlags) michael@0: { michael@0: *aProtocolFlags = URI_NORELATIVE | URI_NOAUTH | URI_INHERITS_SECURITY_CONTEXT | michael@0: URI_LOADABLE_BY_ANYONE | URI_NON_PERSISTABLE | URI_SYNC_LOAD_IS_OK; michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: RtspHandler::NewURI(const nsACString & aSpec, michael@0: const char *aOriginCharset, michael@0: nsIURI *aBaseURI, nsIURI **aResult) michael@0: { michael@0: int32_t port; michael@0: michael@0: nsresult rv = GetDefaultPort(&port); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: nsRefPtr url = new nsStandardURL(); michael@0: rv = url->Init(nsIStandardURL::URLTYPE_AUTHORITY, port, aSpec, michael@0: aOriginCharset, aBaseURI); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: url.forget(aResult); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: RtspHandler::NewChannel(nsIURI *aURI, nsIChannel **aResult) michael@0: { michael@0: bool isRtsp = false; michael@0: nsRefPtr rtspChannel; michael@0: michael@0: nsresult rv = aURI->SchemeIs("rtsp", &isRtsp); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: NS_ENSURE_TRUE(isRtsp, NS_ERROR_UNEXPECTED); michael@0: michael@0: if (IsNeckoChild()) { michael@0: rtspChannel = new RtspChannelChild(aURI); michael@0: } else { michael@0: rtspChannel = new RtspChannelParent(aURI); michael@0: } michael@0: michael@0: rv = rtspChannel->Init(); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: rtspChannel.forget(aResult); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: RtspHandler::AllowPort(int32_t port, const char *scheme, bool *aResult) michael@0: { michael@0: // Do not override any blacklisted ports. michael@0: *aResult = false; michael@0: return NS_OK; michael@0: } michael@0: michael@0: } // namespace net michael@0: } // namespace mozilla