OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 library media_sink_mojom; | 5 library media_sink_mojom; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:mojo/bindings.dart' as bindings; | 7 import 'package:mojo/bindings.dart' as bindings; |
8 import 'package:mojo/core.dart' as core; | 8 import 'package:mojo/core.dart' as core; |
9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; | 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
10 import 'package:mojo_services/mojo/media/media_state.mojom.dart' as media_state_
mojom; | 10 import 'package:mojo_services/mojo/media/media_state.mojom.dart' as media_state_
mojom; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 map["timelineTransform"] = timelineTransform; | 101 map["timelineTransform"] = timelineTransform; |
102 return map; | 102 return map; |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 | 106 |
107 class _MediaSinkGetConsumerParams extends bindings.Struct { | 107 class _MediaSinkGetConsumerParams extends bindings.Struct { |
108 static const List<bindings.StructDataHeader> kVersions = const [ | 108 static const List<bindings.StructDataHeader> kVersions = const [ |
109 const bindings.StructDataHeader(16, 0) | 109 const bindings.StructDataHeader(16, 0) |
110 ]; | 110 ]; |
111 Object consumer = null; | 111 media_transport_mojom.MediaConsumerInterfaceRequest consumer = null; |
112 | 112 |
113 _MediaSinkGetConsumerParams() : super(kVersions.last.size); | 113 _MediaSinkGetConsumerParams() : super(kVersions.last.size); |
114 | 114 |
115 static _MediaSinkGetConsumerParams deserialize(bindings.Message message) { | 115 static _MediaSinkGetConsumerParams deserialize(bindings.Message message) { |
116 var decoder = new bindings.Decoder(message); | 116 var decoder = new bindings.Decoder(message); |
117 var result = decode(decoder); | 117 var result = decode(decoder); |
118 if (decoder.excessHandles != null) { | 118 if (decoder.excessHandles != null) { |
119 decoder.excessHandles.forEach((h) => h.close()); | 119 decoder.excessHandles.forEach((h) => h.close()); |
120 } | 120 } |
121 return result; | 121 return result; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 | 460 |
461 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 461 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => |
462 responseFactory(null); | 462 responseFactory(null); |
463 | 463 |
464 dynamic getAllTypeDefinitions([Function responseFactory]) => | 464 dynamic getAllTypeDefinitions([Function responseFactory]) => |
465 responseFactory(null); | 465 responseFactory(null); |
466 } | 466 } |
467 | 467 |
468 abstract class MediaSink { | 468 abstract class MediaSink { |
469 static const String serviceName = null; | 469 static const String serviceName = null; |
470 void getConsumer(Object consumer); | 470 |
| 471 static service_describer.ServiceDescription _cachedServiceDescription; |
| 472 static service_describer.ServiceDescription get serviceDescription { |
| 473 if (_cachedServiceDescription == null) { |
| 474 _cachedServiceDescription = new _MediaSinkServiceDescription(); |
| 475 } |
| 476 return _cachedServiceDescription; |
| 477 } |
| 478 |
| 479 static MediaSinkProxy connectToService( |
| 480 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 481 MediaSinkProxy p = new MediaSinkProxy.unbound(); |
| 482 String name = serviceName ?? MediaSink.serviceName; |
| 483 if ((name == null) || name.isEmpty) { |
| 484 throw new core.MojoApiError( |
| 485 "If an interface has no ServiceName, then one must be provided."); |
| 486 } |
| 487 s.connectToService(url, p, name); |
| 488 return p; |
| 489 } |
| 490 void getConsumer(media_transport_mojom.MediaConsumerInterfaceRequest consumer)
; |
471 dynamic getStatus(int versionLastSeen,[Function responseFactory = null]); | 491 dynamic getStatus(int versionLastSeen,[Function responseFactory = null]); |
472 void play(); | 492 void play(); |
473 void pause(); | 493 void pause(); |
474 static const int kInitialStatus = 0; | 494 static const int kInitialStatus = 0; |
475 } | 495 } |
476 | 496 |
| 497 abstract class MediaSinkInterface |
| 498 implements bindings.MojoInterface<MediaSink>, |
| 499 MediaSink { |
| 500 factory MediaSinkInterface([MediaSink impl]) => |
| 501 new MediaSinkStub.unbound(impl); |
| 502 factory MediaSinkInterface.fromEndpoint( |
| 503 core.MojoMessagePipeEndpoint endpoint, |
| 504 [MediaSink impl]) => |
| 505 new MediaSinkStub.fromEndpoint(endpoint, impl); |
| 506 } |
| 507 |
| 508 abstract class MediaSinkInterfaceRequest |
| 509 implements bindings.MojoInterface<MediaSink>, |
| 510 MediaSink { |
| 511 factory MediaSinkInterfaceRequest() => |
| 512 new MediaSinkProxy.unbound(); |
| 513 } |
| 514 |
477 class _MediaSinkProxyControl | 515 class _MediaSinkProxyControl |
478 extends bindings.ProxyMessageHandler | 516 extends bindings.ProxyMessageHandler |
479 implements bindings.ProxyControl { | 517 implements bindings.ProxyControl<MediaSink> { |
480 _MediaSinkProxyControl.fromEndpoint( | 518 _MediaSinkProxyControl.fromEndpoint( |
481 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 519 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
482 | 520 |
483 _MediaSinkProxyControl.fromHandle( | 521 _MediaSinkProxyControl.fromHandle( |
484 core.MojoHandle handle) : super.fromHandle(handle); | 522 core.MojoHandle handle) : super.fromHandle(handle); |
485 | 523 |
486 _MediaSinkProxyControl.unbound() : super.unbound(); | 524 _MediaSinkProxyControl.unbound() : super.unbound(); |
487 | 525 |
488 service_describer.ServiceDescription get serviceDescription => | |
489 new _MediaSinkServiceDescription(); | |
490 | |
491 String get serviceName => MediaSink.serviceName; | 526 String get serviceName => MediaSink.serviceName; |
492 | 527 |
493 void handleResponse(bindings.ServiceMessage message) { | 528 void handleResponse(bindings.ServiceMessage message) { |
494 switch (message.header.type) { | 529 switch (message.header.type) { |
495 case _mediaSinkMethodGetStatusName: | 530 case _mediaSinkMethodGetStatusName: |
496 var r = MediaSinkGetStatusResponseParams.deserialize( | 531 var r = MediaSinkGetStatusResponseParams.deserialize( |
497 message.payload); | 532 message.payload); |
498 if (!message.header.hasRequestId) { | 533 if (!message.header.hasRequestId) { |
499 proxyError("Expected a message with a valid request Id."); | 534 proxyError("Expected a message with a valid request Id."); |
500 return; | 535 return; |
(...skipping 11 matching lines...) Expand all Loading... |
512 } | 547 } |
513 c.complete(r); | 548 c.complete(r); |
514 break; | 549 break; |
515 default: | 550 default: |
516 proxyError("Unexpected message type: ${message.header.type}"); | 551 proxyError("Unexpected message type: ${message.header.type}"); |
517 close(immediate: true); | 552 close(immediate: true); |
518 break; | 553 break; |
519 } | 554 } |
520 } | 555 } |
521 | 556 |
| 557 MediaSink get impl => null; |
| 558 set impl(MediaSink _) { |
| 559 throw new core.MojoApiError("The impl of a Proxy cannot be set."); |
| 560 } |
| 561 |
522 @override | 562 @override |
523 String toString() { | 563 String toString() { |
524 var superString = super.toString(); | 564 var superString = super.toString(); |
525 return "_MediaSinkProxyControl($superString)"; | 565 return "_MediaSinkProxyControl($superString)"; |
526 } | 566 } |
527 } | 567 } |
528 | 568 |
529 class MediaSinkProxy | 569 class MediaSinkProxy |
530 extends bindings.Proxy | 570 extends bindings.Proxy<MediaSink> |
531 implements MediaSink { | 571 implements MediaSink, |
| 572 MediaSinkInterface, |
| 573 MediaSinkInterfaceRequest { |
532 MediaSinkProxy.fromEndpoint( | 574 MediaSinkProxy.fromEndpoint( |
533 core.MojoMessagePipeEndpoint endpoint) | 575 core.MojoMessagePipeEndpoint endpoint) |
534 : super(new _MediaSinkProxyControl.fromEndpoint(endpoint)); | 576 : super(new _MediaSinkProxyControl.fromEndpoint(endpoint)); |
535 | 577 |
536 MediaSinkProxy.fromHandle(core.MojoHandle handle) | 578 MediaSinkProxy.fromHandle(core.MojoHandle handle) |
537 : super(new _MediaSinkProxyControl.fromHandle(handle)); | 579 : super(new _MediaSinkProxyControl.fromHandle(handle)); |
538 | 580 |
539 MediaSinkProxy.unbound() | 581 MediaSinkProxy.unbound() |
540 : super(new _MediaSinkProxyControl.unbound()); | 582 : super(new _MediaSinkProxyControl.unbound()); |
541 | 583 |
542 static MediaSinkProxy newFromEndpoint( | 584 static MediaSinkProxy newFromEndpoint( |
543 core.MojoMessagePipeEndpoint endpoint) { | 585 core.MojoMessagePipeEndpoint endpoint) { |
544 assert(endpoint.setDescription("For MediaSinkProxy")); | 586 assert(endpoint.setDescription("For MediaSinkProxy")); |
545 return new MediaSinkProxy.fromEndpoint(endpoint); | 587 return new MediaSinkProxy.fromEndpoint(endpoint); |
546 } | 588 } |
547 | 589 |
548 factory MediaSinkProxy.connectToService( | |
549 bindings.ServiceConnector s, String url, [String serviceName]) { | |
550 MediaSinkProxy p = new MediaSinkProxy.unbound(); | |
551 s.connectToService(url, p, serviceName); | |
552 return p; | |
553 } | |
554 | 590 |
555 | 591 void getConsumer(media_transport_mojom.MediaConsumerInterfaceRequest consumer)
{ |
556 void getConsumer(Object consumer) { | |
557 if (!ctrl.isBound) { | 592 if (!ctrl.isBound) { |
558 ctrl.proxyError("The Proxy is closed."); | 593 ctrl.proxyError("The Proxy is closed."); |
559 return; | 594 return; |
560 } | 595 } |
561 var params = new _MediaSinkGetConsumerParams(); | 596 var params = new _MediaSinkGetConsumerParams(); |
562 params.consumer = consumer; | 597 params.consumer = consumer; |
563 ctrl.sendMessage(params, | 598 ctrl.sendMessage(params, |
564 _mediaSinkMethodGetConsumerName); | 599 _mediaSinkMethodGetConsumerName); |
565 } | 600 } |
566 dynamic getStatus(int versionLastSeen,[Function responseFactory = null]) { | 601 dynamic getStatus(int versionLastSeen,[Function responseFactory = null]) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 } | 639 } |
605 | 640 |
606 _MediaSinkStubControl.fromHandle( | 641 _MediaSinkStubControl.fromHandle( |
607 core.MojoHandle handle, [MediaSink impl]) | 642 core.MojoHandle handle, [MediaSink impl]) |
608 : super.fromHandle(handle, autoBegin: impl != null) { | 643 : super.fromHandle(handle, autoBegin: impl != null) { |
609 _impl = impl; | 644 _impl = impl; |
610 } | 645 } |
611 | 646 |
612 _MediaSinkStubControl.unbound([this._impl]) : super.unbound(); | 647 _MediaSinkStubControl.unbound([this._impl]) : super.unbound(); |
613 | 648 |
| 649 String get serviceName => MediaSink.serviceName; |
| 650 |
614 | 651 |
615 MediaSinkGetStatusResponseParams _mediaSinkGetStatusResponseParamsFactory(int
version, MediaSinkStatus status) { | 652 MediaSinkGetStatusResponseParams _mediaSinkGetStatusResponseParamsFactory(int
version, MediaSinkStatus status) { |
616 var result = new MediaSinkGetStatusResponseParams(); | 653 var result = new MediaSinkGetStatusResponseParams(); |
617 result.version = version; | 654 result.version = version; |
618 result.status = status; | 655 result.status = status; |
619 return result; | 656 return result; |
620 } | 657 } |
621 | 658 |
622 dynamic handleMessage(bindings.ServiceMessage message) { | 659 dynamic handleMessage(bindings.ServiceMessage message) { |
623 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 660 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 } | 725 } |
689 } | 726 } |
690 | 727 |
691 @override | 728 @override |
692 String toString() { | 729 String toString() { |
693 var superString = super.toString(); | 730 var superString = super.toString(); |
694 return "_MediaSinkStubControl($superString)"; | 731 return "_MediaSinkStubControl($superString)"; |
695 } | 732 } |
696 | 733 |
697 int get version => 0; | 734 int get version => 0; |
698 | |
699 static service_describer.ServiceDescription _cachedServiceDescription; | |
700 static service_describer.ServiceDescription get serviceDescription { | |
701 if (_cachedServiceDescription == null) { | |
702 _cachedServiceDescription = new _MediaSinkServiceDescription(); | |
703 } | |
704 return _cachedServiceDescription; | |
705 } | |
706 } | 735 } |
707 | 736 |
708 class MediaSinkStub | 737 class MediaSinkStub |
709 extends bindings.Stub<MediaSink> | 738 extends bindings.Stub<MediaSink> |
710 implements MediaSink { | 739 implements MediaSink, |
| 740 MediaSinkInterface, |
| 741 MediaSinkInterfaceRequest { |
| 742 MediaSinkStub.unbound([MediaSink impl]) |
| 743 : super(new _MediaSinkStubControl.unbound(impl)); |
| 744 |
711 MediaSinkStub.fromEndpoint( | 745 MediaSinkStub.fromEndpoint( |
712 core.MojoMessagePipeEndpoint endpoint, [MediaSink impl]) | 746 core.MojoMessagePipeEndpoint endpoint, [MediaSink impl]) |
713 : super(new _MediaSinkStubControl.fromEndpoint(endpoint, impl)); | 747 : super(new _MediaSinkStubControl.fromEndpoint(endpoint, impl)); |
714 | 748 |
715 MediaSinkStub.fromHandle( | 749 MediaSinkStub.fromHandle( |
716 core.MojoHandle handle, [MediaSink impl]) | 750 core.MojoHandle handle, [MediaSink impl]) |
717 : super(new _MediaSinkStubControl.fromHandle(handle, impl)); | 751 : super(new _MediaSinkStubControl.fromHandle(handle, impl)); |
718 | 752 |
719 MediaSinkStub.unbound([MediaSink impl]) | |
720 : super(new _MediaSinkStubControl.unbound(impl)); | |
721 | |
722 static MediaSinkStub newFromEndpoint( | 753 static MediaSinkStub newFromEndpoint( |
723 core.MojoMessagePipeEndpoint endpoint) { | 754 core.MojoMessagePipeEndpoint endpoint) { |
724 assert(endpoint.setDescription("For MediaSinkStub")); | 755 assert(endpoint.setDescription("For MediaSinkStub")); |
725 return new MediaSinkStub.fromEndpoint(endpoint); | 756 return new MediaSinkStub.fromEndpoint(endpoint); |
726 } | 757 } |
727 | 758 |
728 static service_describer.ServiceDescription get serviceDescription => | |
729 _MediaSinkStubControl.serviceDescription; | |
730 | 759 |
731 | 760 void getConsumer(media_transport_mojom.MediaConsumerInterfaceRequest consumer)
{ |
732 void getConsumer(Object consumer) { | |
733 return impl.getConsumer(consumer); | 761 return impl.getConsumer(consumer); |
734 } | 762 } |
735 dynamic getStatus(int versionLastSeen,[Function responseFactory = null]) { | 763 dynamic getStatus(int versionLastSeen,[Function responseFactory = null]) { |
736 return impl.getStatus(versionLastSeen,responseFactory); | 764 return impl.getStatus(versionLastSeen,responseFactory); |
737 } | 765 } |
738 void play() { | 766 void play() { |
739 return impl.play(); | 767 return impl.play(); |
740 } | 768 } |
741 void pause() { | 769 void pause() { |
742 return impl.pause(); | 770 return impl.pause(); |
743 } | 771 } |
744 } | 772 } |
745 | 773 |
746 | 774 |
747 | 775 |
OLD | NEW |