本文整理汇总了Java中org.chromium.chrome.browser.media.router.MediaRoute类的典型用法代码示例。如果您正苦于以下问题:Java MediaRoute类的具体用法?Java MediaRoute怎么用?Java MediaRoute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MediaRoute类属于org.chromium.chrome.browser.media.router包,在下文中一共展示了MediaRoute类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: launchSession
import org.chromium.chrome.browser.media.router.MediaRoute; //导入依赖的package包/类
private void launchSession(CreateRouteRequest request) {
MediaSink sink = request.getSink();
MediaSource source = request.getSource();
MediaRoute route = new MediaRoute(
sink.getId(), source.getUrn(), request.getPresentationId());
addRoute(route, request.getOrigin(), request.getTabId());
mManager.onRouteCreated(route.id, route.sinkId, request.getNativeRequestId(), this, true);
if (source.getClientId() != null) {
ClientRecord clientRecord = mClientRecords.get(source.getClientId());
if (clientRecord != null) {
sendReceiverAction(clientRecord.routeId, sink, source.getClientId(), "cast");
}
}
request.start(mApplicationContext);
}
示例2: joinRoute
import org.chromium.chrome.browser.media.router.MediaRoute; //导入依赖的package包/类
@Override
public void joinRoute(String sourceId, String presentationId, String origin, int tabId,
int nativeRequestId) {
MediaSource source = MediaSource.from(sourceId);
if (source == null || source.getClientId() == null) {
mManager.onRouteRequestError("Unsupported presentation URL", nativeRequestId);
return;
}
if (mSession == null) {
mManager.onRouteRequestError("No presentation", nativeRequestId);
return;
}
if (!canJoinExistingSession(presentationId, origin, tabId, source)) {
mManager.onRouteRequestError("No matching route", nativeRequestId);
return;
}
MediaRoute route = new MediaRoute(mSession.getSinkId(), sourceId, presentationId);
addRoute(route, origin, tabId);
mManager.onRouteCreated(route.id, route.sinkId, nativeRequestId, this, false);
}
示例3: closeRoute
import org.chromium.chrome.browser.media.router.MediaRoute; //导入依赖的package包/类
@Override
public void closeRoute(String routeId) {
MediaRoute route = mRoutes.get(routeId);
if (route == null) return;
if (mSession == null) {
mRoutes.remove(routeId);
return;
}
ClientRecord client = getClientRecordByRouteId(routeId);
if (client != null) {
MediaSink sink = MediaSink.fromSinkId(mSession.getSinkId(), mAndroidMediaRouter);
if (sink != null) sendReceiverAction(routeId, sink, client.clientId, "stop");
}
mSession.stopApplication();
}
示例4: addRoute
import org.chromium.chrome.browser.media.router.MediaRoute; //导入依赖的package包/类
private void addRoute(MediaRoute route, String origin, int tabId) {
mRoutes.put(route.id, route);
MediaSource source = MediaSource.from(route.sourceId);
final String clientId = source.getClientId();
if (clientId == null || mClientRecords.get(clientId) != null) return;
mClientRecords.put(clientId,
new ClientRecord(
route.id,
clientId,
source.getApplicationId(),
source.getAutoJoinPolicy(),
origin,
tabId));
}
示例5: launchSession
import org.chromium.chrome.browser.media.router.MediaRoute; //导入依赖的package包/类
private void launchSession(CreateRouteRequest request) {
MediaSink sink = request.getSink();
MediaSource source = request.getSource();
MediaRoute route = new MediaRoute(
sink.getId(), source.getUrn(), request.getPresentationId());
addRoute(route, request.getOrigin(), request.getTabId());
mManager.onRouteCreated(route.id, route.sinkId, request.getNativeRequestId(), this, true);
if (source.getClientId() != null) {
ClientRecord clientRecord = mClientRecords.get(source.getClientId());
if (clientRecord != null) {
sendReceiverAction(clientRecord.routeId, sink, source.getClientId(), "cast");
}
}
request.start();
}
示例6: closeRoute
import org.chromium.chrome.browser.media.router.MediaRoute; //导入依赖的package包/类
@Override
public void closeRoute(String routeId) {
MediaRoute route = mRoutes.get(routeId);
if (route == null) return;
if (mSession == null) {
mRoutes.remove(routeId);
mManager.onRouteClosed(routeId);
return;
}
ClientRecord client = getClientRecordByRouteId(routeId);
if (client != null && mAndroidMediaRouter != null) {
MediaSink sink = MediaSink.fromSinkId(mSession.getSinkId(), mAndroidMediaRouter);
if (sink != null) sendReceiverAction(routeId, sink, client.clientId, "stop");
}
mSession.stopApplication();
}
示例7: addRoute
import org.chromium.chrome.browser.media.router.MediaRoute; //导入依赖的package包/类
@VisibleForTesting
void addRoute(MediaRoute route, String origin, int tabId) {
mRoutes.put(route.id, route);
MediaSource source = MediaSource.from(route.sourceId);
final String clientId = source.getClientId();
if (clientId == null || mClientRecords.get(clientId) != null) return;
mClientRecords.put(clientId,
new ClientRecord(
route.id,
clientId,
source.getApplicationId(),
source.getAutoJoinPolicy(),
origin,
tabId));
}
示例8: canJoinExistingSession
import org.chromium.chrome.browser.media.router.MediaRoute; //导入依赖的package包/类
private boolean canJoinExistingSession(String presentationId, String origin, int tabId,
MediaSource source) {
if (AUTO_JOIN_PRESENTATION_ID.equals(presentationId)) {
return canAutoJoin(source, origin, tabId);
} else if (presentationId.startsWith(PRESENTATION_ID_SESSION_ID_PREFIX)) {
String sessionId = presentationId.substring(PRESENTATION_ID_SESSION_ID_PREFIX.length());
if (mSession.getSessionId().equals(sessionId)) return true;
} else {
for (MediaRoute route : mRoutes.values()) {
if (route.presentationId.equals(presentationId)) return true;
}
}
return false;
}