Bug 1322602 - remove Fennec-to-FxOSTV video casting. r=rbarker
authorShih-Chiang Chien <schien@mozilla.com>
Thu, 08 Dec 2016 16:02:13 -1000
changeset 325579 14617919dacee1191582e731509fd55d06b11d27
parent 325578 641f5b1431fc7bcd4dd8b8124204ea238e289e51
child 325580 5cc901aa30a2f8ce528082f8b5a4f06c34fef363
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersrbarker
bugs1322602
milestone53.0a1
Bug 1322602 - remove Fennec-to-FxOSTV video casting. r=rbarker MozReview-Commit-ID: KjEJUPkgRLo
mobile/android/app/mobile.js
mobile/android/chrome/content/CastingApps.js
mobile/android/chrome/content/browser.js
toolkit/modules/moz.build
toolkit/modules/secondscreen/PresentationApp.jsm
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -912,19 +912,16 @@ pref("identity.sync.tokenserver.uri", "h
 
 #ifndef RELEASE_OR_BETA
 // Enable Presentation API on Nightly
 pref("dom.presentation.enabled", true);
 pref("dom.presentation.controller.enabled", true); // enable 1-UA mode
 pref("dom.presentation.receiver.enabled", true); // enable 1-UA mode
 #endif
 
-pref("dom.presentation.discovery.enabled", true);
-pref("dom.presentation.discovery.legacy.enabled", true); // for TV 2.5 backward capability
-
 pref("dom.audiochannel.audioCompeting", true);
 pref("dom.audiochannel.mediaControl", true);
 
 // Space separated list of URLS that are allowed to send objects (instead of
 // only strings) through webchannels. This list is duplicated in browser/app/profile/firefox.js
 pref("webchannel.allowObject.urlWhitelist", "https://accounts.firefox.com https://content.cdn.mozilla.net https://input.mozilla.org https://support.mozilla.org https://install.mozilla.org");
 
 pref("media.openUnsupportedTypeWithExternalApp", true);
--- a/mobile/android/chrome/content/CastingApps.js
+++ b/mobile/android/chrome/content/CastingApps.js
@@ -54,74 +54,16 @@ var mediaPlayerDevice = {
       uuid: display.uuid,
       manufacturer: display.manufacturer,
       modelName: display.modelName,
       mirror: display.mirror
     };
   }
 };
 
-var fxOSTVDevice = {
-  id: "app://fling-player.gaiamobile.org",
-  target: "app://fling-player.gaiamobile.org/index.html",
-  factory: function(aService) {
-    Cu.import("resource://gre/modules/PresentationApp.jsm");
-    let request = new window.PresentationRequest(this.target);
-    return new PresentationApp(aService, request);
-  },
-  init: function() {
-    Services.obs.addObserver(this, "presentation-device-change", false);
-    SimpleServiceDiscovery.addExternalDiscovery(this);
-  },
-  observe: function(subject, topic, data) {
-    let device = subject.QueryInterface(Ci.nsIPresentationDevice);
-    let service = this.toService(device);
-    switch (data) {
-      case "add":
-        SimpleServiceDiscovery.addService(service);
-        break;
-      case "update":
-        SimpleServiceDiscovery.updateService(service);
-        break;
-      case "remove":
-        if(SimpleServiceDiscovery.findServiceForID(device.id)) {
-          SimpleServiceDiscovery.removeService(device.id);
-        }
-        break;
-    }
-  },
-  toService: function(device) {
-    return {
-      location: device.id,
-      target: fxOSTVDevice.target,
-      friendlyName: device.name,
-      uuid: device.id,
-      manufacturer: "Firefox OS TV",
-      modelName: "Firefox OS TV",
-    };
-  },
-  startDiscovery: function() {
-    window.navigator.mozPresentationDeviceInfo.forceDiscovery();
-
-    // need to update the lastPing time for known device.
-    window.navigator.mozPresentationDeviceInfo.getAll()
-    .then(function(devices) {
-      for (let device of devices) {
-        let service = fxOSTVDevice.toService(device);
-        SimpleServiceDiscovery.addService(service);
-      }
-    });
-  },
-  stopDiscovery: function() {
-    // do nothing
-  },
-  types: ["video/mp4", "video/webm"],
-  extensions: ["mp4", "webm"],
-};
-
 var CastingApps = {
   _castMenuId: -1,
   mirrorStartMenuId: -1,
   mirrorStopMenuId: -1,
   _blocked: null,
   _bound: null,
   _interval: 120 * 1000, // 120 seconds
 
@@ -132,22 +74,16 @@ var CastingApps = {
 
     // Register targets
     SimpleServiceDiscovery.registerDevice(rokuDevice);
 
     // MediaPlayerDevice will notify us any time the native device list changes.
     mediaPlayerDevice.init();
     SimpleServiceDiscovery.registerDevice(mediaPlayerDevice);
 
-    // Presentation Device will notify us any time the available device list changes.
-    if (window.PresentationRequest) {
-      fxOSTVDevice.init();
-      SimpleServiceDiscovery.registerDevice(fxOSTVDevice);
-    }
-
     // Search for devices continuously
     SimpleServiceDiscovery.search(this._interval);
 
     this._castMenuId = NativeWindow.contextmenus.add(
       Strings.browser.GetStringFromName("contextmenu.sendToDevice"),
       this.filterCast,
       this.handleContextMenu.bind(this)
     );
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -509,17 +509,16 @@ var BrowserApp = {
 
     // Notify Java that Gecko has loaded.
     Messaging.sendRequest({ type: "Gecko:Ready" });
 
     this.deck.addEventListener("DOMContentLoaded", function BrowserApp_delayedStartup() {
       BrowserApp.deck.removeEventListener("DOMContentLoaded", BrowserApp_delayedStartup, false);
 
       InitLater(() => Cu.import("resource://gre/modules/NotificationDB.jsm"));
-      InitLater(() => Cu.import("resource://gre/modules/PresentationDeviceInfoManager.jsm"));
 
       InitLater(() => Services.obs.notifyObservers(window, "browser-delayed-startup-finished", ""));
       InitLater(() => Messaging.sendRequest({ type: "Gecko:DelayedStartup" }));
 
       if (!AppConstants.RELEASE_OR_BETA) {
         InitLater(() => WebcompatReporter.init());
       }
 
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -73,17 +73,16 @@ EXTRA_JS_MODULES += [
     'PromiseUtils.jsm',
     'PropertyListUtils.jsm',
     'RemoteController.jsm',
     'RemoteFinder.jsm',
     'RemotePageManager.jsm',
     'RemoteSecurityUI.jsm',
     'RemoteWebProgress.jsm',
     'ResetProfile.jsm',
-    'secondscreen/PresentationApp.jsm',
     'secondscreen/RokuApp.jsm',
     'secondscreen/SimpleServiceDiscovery.jsm',
     'SelectContentHelper.jsm',
     'SelectParentHelper.jsm',
     'Services.jsm',
     'SessionRecorder.jsm',
     'sessionstore/FormData.jsm',
     'sessionstore/ScrollPosition.jsm',
deleted file mode 100644
--- a/toolkit/modules/secondscreen/PresentationApp.jsm
+++ /dev/null
@@ -1,190 +0,0 @@
-// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
-/* 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/. */
-
-"use strict";
-
-this.EXPORTED_SYMBOLS = ["PresentationApp"];
-
-const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
-
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyGetter(this, "sysInfo", () => {
-  return Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2);
-});
-
-const DEBUG = false;
-
-const STATE_UNINIT = "uninitialized" // RemoteMedia status
-const STATE_STARTED = "started"; // RemoteMedia status
-const STATE_PAUSED = "paused"; // RemoteMedia status
-const STATE_SHUTDOWN = "shutdown"; // RemoteMedia status
-
-function debug(msg) {
-  Services.console.logStringMessage("PresentationApp: " + msg);
-}
-
-// PresentationApp is a wrapper for interacting with a Presentation Receiver Device.
-function PresentationApp(service, request) {
-  this.service = service;
-  this.request = request;
-}
-
-PresentationApp.prototype = {
-  start: function start(callback) {
-    this.request.startWithDevice(this.service.uuid)
-    .then((session) => {
-      this._session = session;
-      if (callback) {
-        session.addEventListener('connect', () => {
-          callback(true);
-        });
-      }
-    }, () => {
-      if (callback) {
-        callback(false);
-      }
-    });
-  },
-
-  stop: function stop(callback) {
-    if (this._session && this._session.state === "connected") {
-      this._session.terminate();
-    }
-
-    delete this._session;
-
-    if (callback) {
-      callback(true);
-    }
-  },
-
-  remoteMedia: function remoteMedia(callback, listener) {
-    if (callback) {
-      if (!this._session) {
-        callback();
-        return;
-      }
-
-      callback(new RemoteMedia(this._session, listener));
-    }
-  }
-}
-
-/* RemoteMedia provides a wrapper for using Presentation API to control Firefox TV app.
- * The server implementation must be built into the Firefox TV receiver app.
- * see https://github.com/mozilla-b2g/gaia/tree/master/tv_apps/fling-player
- */
-function RemoteMedia(session, listener) {
-  this._session = session ;
-  this._listener = listener;
-  this._status = STATE_UNINIT;
-
-  this._session.addEventListener("message", this);
-  this._session.addEventListener("terminate", this);
-
-  if (this._listener && "onRemoteMediaStart" in this._listener) {
-    Services.tm.mainThread.dispatch((function() {
-      this._listener.onRemoteMediaStart(this);
-    }).bind(this), Ci.nsIThread.DISPATCH_NORMAL);
-  }
-}
-
-RemoteMedia.prototype = {
-  _seq: 0,
-
-  handleEvent: function(e) {
-    switch (e.type) {
-      case "message":
-        this._onmessage(e);
-        break;
-      case "terminate":
-        this._onterminate(e);
-        break;
-    }
-  },
-
-  _onmessage: function(e) {
-    DEBUG && debug("onmessage: " + e.data);
-    if (this.status === STATE_SHUTDOWN) {
-      return;
-    }
-
-    if (e.data.indexOf("stopped") > -1) {
-      if (this.status !== STATE_PAUSED) {
-        this._status = STATE_PAUSED;
-        if (this._listener && "onRemoteMediaStatus" in this._listener) {
-          this._listener.onRemoteMediaStatus(this);
-        }
-      }
-    } else if (e.data.indexOf("playing") > -1) {
-      if (this.status !== STATE_STARTED) {
-        this._status = STATE_STARTED;
-        if (this._listener && "onRemoteMediaStatus" in this._listener) {
-          this._listener.onRemoteMediaStatus(this);
-        }
-      }
-    }
-  },
-
-  _onterminate: function(e) {
-    DEBUG && debug("onterminate: " + this._session.state);
-    this._status = STATE_SHUTDOWN;
-    if (this._listener && "onRemoteMediaStop" in this._listener) {
-      this._listener.onRemoteMediaStop(this);
-    }
-  },
-
-  _sendCommand: function(command, data) {
-    let msg = {
-      'type': command,
-      'seq': ++this._seq
-    };
-
-    if (data) {
-      for (var k in data) {
-        msg[k] = data[k];
-      }
-    }
-
-    let raw = JSON.stringify(msg);
-    DEBUG && debug("send command: " + raw);
-
-    this._session.send(raw);
-  },
-
-  shutdown: function shutdown() {
-    DEBUG && debug("RemoteMedia - shutdown");
-    this._sendCommand("close");
-  },
-
-  play: function play() {
-    DEBUG && debug("RemoteMedia - play");
-    this._sendCommand("play");
-  },
-
-  pause: function pause() {
-    DEBUG && debug("RemoteMedia - pause");
-    this._sendCommand("pause");
-  },
-
-  load: function load(data) {
-    DEBUG && debug("RemoteMedia - load: " + data);
-    this._sendCommand("load", { "url": data.source });
-
-    let deviceName;
-    if (Services.appinfo.widgetToolkit == "android") {
-      deviceName = sysInfo.get("device");
-    } else {
-      deviceName = sysInfo.get("host");
-    }
-    this._sendCommand("device-info", { "displayName": deviceName });
-  },
-
-  get status() {
-    return this._status;
-  }
-}