DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Mercurial (31ec81b5d7bb)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et tw=80 : */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "RtspChannel.h"
#include "RtspHandler.h"
#include "nsILoadGroup.h"
#include "nsIInterfaceRequestor.h"
#include "nsIURI.h"
#include "nsAutoPtr.h"
#include "nsStandardURL.h"
#include "mozilla/net/NeckoChild.h"

namespace mozilla {
namespace net {

NS_IMPL_ISUPPORTS1(RtspHandler, nsIProtocolHandler)

//-----------------------------------------------------------------------------
// RtspHandler::nsIProtocolHandler
//-----------------------------------------------------------------------------

NS_IMETHODIMP
RtspHandler::GetScheme(nsACString &aScheme)
{
  aScheme.AssignLiteral("rtsp");
  return NS_OK;
}

NS_IMETHODIMP
RtspHandler::GetDefaultPort(int32_t *aDefaultPort)
{
  *aDefaultPort = kDefaultRtspPort;
  return NS_OK;
}

NS_IMETHODIMP
RtspHandler::GetProtocolFlags(uint32_t *aProtocolFlags)
{
  *aProtocolFlags = URI_NORELATIVE | URI_NOAUTH | URI_INHERITS_SECURITY_CONTEXT |
    URI_LOADABLE_BY_ANYONE | URI_NON_PERSISTABLE | URI_SYNC_LOAD_IS_OK;

  return NS_OK;
}

NS_IMETHODIMP
RtspHandler::NewURI(const nsACString & aSpec,
                    const char *aOriginCharset,
                    nsIURI *aBaseURI, nsIURI **aResult)
{
  int32_t port;

  nsresult rv = GetDefaultPort(&port);
  NS_ENSURE_SUCCESS(rv, rv);

  nsRefPtr<nsStandardURL> url = new nsStandardURL();
  rv = url->Init(nsIStandardURL::URLTYPE_AUTHORITY, port, aSpec,
                 aOriginCharset, aBaseURI);
  NS_ENSURE_SUCCESS(rv, rv);

  url.forget(aResult);
  return NS_OK;
}

NS_IMETHODIMP
RtspHandler::NewChannel(nsIURI *aURI, nsIChannel **aResult)
{
  bool isRtsp = false;
  nsRefPtr<RtspChannel> rtspChannel;

  nsresult rv = aURI->SchemeIs("rtsp", &isRtsp);
  NS_ENSURE_SUCCESS(rv, rv);
  NS_ENSURE_TRUE(isRtsp, NS_ERROR_UNEXPECTED);

  rtspChannel = new RtspChannel();

  rv = rtspChannel->Init(aURI);
  NS_ENSURE_SUCCESS(rv, rv);

  rtspChannel.forget(aResult);
  return NS_OK;
}

NS_IMETHODIMP
RtspHandler::AllowPort(int32_t port, const char *scheme, bool *aResult)
{
  // Do not override any blacklisted ports.
  *aResult = false;
  return NS_OK;
}

} // namespace net
} // namespace mozilla