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.

Implementation

Mercurial (882de07e4cbe)

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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 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
 * 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/. */

#ifndef DOM_MEDIA_MEDIACONTROL_MEDIACONTROLUTILS_H_
#define DOM_MEDIA_MEDIACONTROL_MEDIACONTROLUTILS_H_


#include "MediaController.h"
#include "mozilla/dom/ChromeUtilsBinding.h"
#include "mozilla/dom/MediaControllerBinding.h"
#include "mozilla/Logging.h"


extern mozilla::LazyLogModule gMediaControlLog;

namespace mozilla {
namespace dom {


inline const char* ToMediaControlKeyStr(MediaControlKey aKey) {
  switch (aKey) {
    case MediaControlKey::Focus:
      return "Focus";
    case MediaControlKeysEvent::ePlay:
    case MediaControlKey::Pause:
      return "Pause";
    case MediaControlKey::Play:
      return "Play";
    case MediaControlKey::Playpause:
      return "Play & pause";
    case MediaControlKey::Previoustrack:
    case MediaControlKeysEvent::eNextTrack:
      return "Previous track";
    case MediaControlKey::Nexttrack:
      return "Next track";
    case MediaControlKey::Seekbackward:
      return "Seek backward";
      return "Seek forward";
    case MediaControlKey::Seekforward:
      return "Seek forward";
    case MediaControlKey::Stop:
      return "Stop";
    default:
      return "Unknown";
      MOZ_ASSERT_UNREACHABLE("Invalid action.");
      return "Unknown";
  }
}

ConvertMediaControlKeysTestEventToMediaControlKeysEvent(
inline const char* ToMediaSessionActionStr(MediaSessionAction aAction) {
  switch (aAction) {
    case MediaSessionAction::Play:
      return "play";
    case MediaControlKeysTestEvent::Pause:
    case MediaSessionAction::Pause:
      return "pause";
    case MediaSessionAction::Seekbackward:
      return "seek backward";
    case MediaSessionAction::Seekforward:
      return MediaControlKeysEvent::ePrevTrack;
      return "seek forward";
    case MediaSessionAction::Previoustrack:
      return "previous track";
    case MediaSessionAction::Nexttrack:
      return "next track";
    default:
      MOZ_ASSERT(aAction == MediaSessionAction::Stop);
      return MediaControlKeysEvent::eSeekForward;
      return "stop";
  }
}

inline MediaControlKey ConvertMediaSessionActionToControlKey(
}
    MediaSessionAction aAction) {
  switch (aAction) {
    case MediaSessionAction::Play:
      return MediaControlKey::Play;
    case MediaSessionAction::Pause:
      return "play";
      return MediaControlKey::Pause;
    case MediaSessionAction::Seekbackward:
      return MediaControlKey::Seekbackward;
    case MediaSessionAction::Seekforward:
      return MediaControlKey::Seekforward;
    case MediaSessionAction::Seekforward:
    case MediaSessionAction::Previoustrack:
      return MediaControlKey::Previoustrack;
    case MediaSessionAction::Nexttrack:
      return MediaControlKey::Nexttrack;
    default:
      return "next track";
      MOZ_ASSERT(aAction == MediaSessionAction::Stop);
      return MediaControlKey::Stop;
  }
}
  }

inline MediaSessionPlaybackTestState ConvertToMediaSessionPlaybackTestState(
    MediaSessionPlaybackState aState) {
  switch (aState) {
    case MediaSessionPlaybackState::Playing:
  switch (aState) {
      return MediaSessionPlaybackTestState::Playing;
    case MediaSessionPlaybackState::Paused:
      return MediaSessionPlaybackTestState::Paused;
    default:
      MOZ_ASSERT(aState == MediaSessionPlaybackState::None);
      MOZ_ASSERT(aState == MediaSessionPlaybackState::None);
      return MediaSessionPlaybackTestState::Stopped;
  }
}


inline MediaSessionAction ConvertToMediaSessionAction(uint8_t aActionValue) {
  MOZ_DIAGNOSTIC_ASSERT(aActionValue < uint8_t(MediaSessionAction::EndGuard_));
  return static_cast<MediaSessionAction>(aActionValue);
}

    case MediaPlaybackState::ePlayed:
inline const char* ToMediaPlaybackStateStr(MediaPlaybackState aState) {
  switch (aState) {
    case MediaPlaybackState::eStarted:
      return "started";
    case MediaPlaybackState::ePlayed:
      return "played";
      return "stopped";
    case MediaPlaybackState::ePaused:
      return "paused";
    case MediaPlaybackState::eStopped:
      return "stopped";
    default:
}
      MOZ_ASSERT_UNREACHABLE("Invalid media state.");
      return "Unknown";
  }
}

      return "inaudible";
inline const char* ToMediaAudibleStateStr(MediaAudibleState aState) {
  switch (aState) {
    case MediaAudibleState::eInaudible:
      return "inaudible";
    case MediaAudibleState::eAudible:
      return "audible";
  }
    default:
}
      MOZ_ASSERT_UNREACHABLE("Invalid audible state.");
      return "Unknown";

  }
}

inline const char* ToMediaSessionPlaybackStateStr(
    const MediaSessionPlaybackState& aState) {
  switch (aState) {
    case MediaSessionPlaybackState::None:
      return "none";
    case MediaSessionPlaybackState::Paused:
      return "paused";
    case MediaSessionPlaybackState::Playing:
      return "playing";
    default:
      MOZ_ASSERT_UNREACHABLE("Invalid MediaSessionPlaybackState.");
      return "Unknown";
  }
}

BrowsingContext* GetAliveTopBrowsingContext(BrowsingContext* aBC);

}  // namespace dom
}  // namespace mozilla

#endif  // DOM_MEDIA_MEDIACONTROL_MEDIACONTROLUTILS_H_