| 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_factory_mojom; | 5 library media_factory_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_demux.mojom.dart' as media_demux_
mojom; | 10 import 'package:mojo_services/mojo/media/media_demux.mojom.dart' as media_demux_
mojom; |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 static const String serviceName = "mojo::media::MediaFactory"; | 588 static const String serviceName = "mojo::media::MediaFactory"; |
| 589 void createPlayer(Object reader, Object player); | 589 void createPlayer(Object reader, Object player); |
| 590 void createSource(Object reader, List<media_types_mojom.MediaTypeSet> allowedM
ediaTypes, Object source); | 590 void createSource(Object reader, List<media_types_mojom.MediaTypeSet> allowedM
ediaTypes, Object source); |
| 591 void createSink(String destinationUrl, media_types_mojom.MediaType mediaType,
Object sink); | 591 void createSink(String destinationUrl, media_types_mojom.MediaType mediaType,
Object sink); |
| 592 void createDemux(Object reader, Object demux); | 592 void createDemux(Object reader, Object demux); |
| 593 void createDecoder(media_types_mojom.MediaType inputMediaType, Object decoder)
; | 593 void createDecoder(media_types_mojom.MediaType inputMediaType, Object decoder)
; |
| 594 void createNetworkReader(String url, Object reader); | 594 void createNetworkReader(String url, Object reader); |
| 595 } | 595 } |
| 596 | 596 |
| 597 | 597 |
| 598 class _MediaFactoryProxyImpl extends bindings.Proxy { | 598 class _MediaFactoryProxyControl extends bindings.ProxyMessageHandler |
| 599 _MediaFactoryProxyImpl.fromEndpoint( | 599 implements bindings.ProxyControl { |
| 600 _MediaFactoryProxyControl.fromEndpoint( |
| 600 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 601 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
| 601 | 602 |
| 602 _MediaFactoryProxyImpl.fromHandle(core.MojoHandle handle) : | 603 _MediaFactoryProxyControl.fromHandle( |
| 603 super.fromHandle(handle); | 604 core.MojoHandle handle) : super.fromHandle(handle); |
| 604 | 605 |
| 605 _MediaFactoryProxyImpl.unbound() : super.unbound(); | 606 _MediaFactoryProxyControl.unbound() : super.unbound(); |
| 606 | |
| 607 static _MediaFactoryProxyImpl newFromEndpoint( | |
| 608 core.MojoMessagePipeEndpoint endpoint) { | |
| 609 assert(endpoint.setDescription("For _MediaFactoryProxyImpl")); | |
| 610 return new _MediaFactoryProxyImpl.fromEndpoint(endpoint); | |
| 611 } | |
| 612 | 607 |
| 613 service_describer.ServiceDescription get serviceDescription => | 608 service_describer.ServiceDescription get serviceDescription => |
| 614 new _MediaFactoryServiceDescription(); | 609 new _MediaFactoryServiceDescription(); |
| 615 | 610 |
| 611 String get serviceName => MediaFactory.serviceName; |
| 612 |
| 613 @override |
| 616 void handleResponse(bindings.ServiceMessage message) { | 614 void handleResponse(bindings.ServiceMessage message) { |
| 617 switch (message.header.type) { | 615 switch (message.header.type) { |
| 618 default: | 616 default: |
| 619 proxyError("Unexpected message type: ${message.header.type}"); | 617 proxyError("Unexpected message type: ${message.header.type}"); |
| 620 close(immediate: true); | 618 close(immediate: true); |
| 621 break; | 619 break; |
| 622 } | 620 } |
| 623 } | 621 } |
| 624 | 622 |
| 623 @override |
| 625 String toString() { | 624 String toString() { |
| 626 var superString = super.toString(); | 625 var superString = super.toString(); |
| 627 return "_MediaFactoryProxyImpl($superString)"; | 626 return "_MediaFactoryProxyControl($superString)"; |
| 628 } | 627 } |
| 629 } | 628 } |
| 630 | 629 |
| 631 | 630 |
| 632 class _MediaFactoryProxyCalls implements MediaFactory { | 631 class MediaFactoryProxy extends bindings.Proxy |
| 633 _MediaFactoryProxyImpl _proxyImpl; | 632 implements MediaFactory { |
| 633 MediaFactoryProxy.fromEndpoint( |
| 634 core.MojoMessagePipeEndpoint endpoint) |
| 635 : super(new _MediaFactoryProxyControl.fromEndpoint(endpoint)); |
| 634 | 636 |
| 635 _MediaFactoryProxyCalls(this._proxyImpl); | 637 MediaFactoryProxy.fromHandle(core.MojoHandle handle) |
| 636 void createPlayer(Object reader, Object player) { | 638 : super(new _MediaFactoryProxyControl.fromHandle(handle)); |
| 637 if (!_proxyImpl.isBound) { | |
| 638 _proxyImpl.proxyError("The Proxy is closed."); | |
| 639 return; | |
| 640 } | |
| 641 var params = new _MediaFactoryCreatePlayerParams(); | |
| 642 params.reader = reader; | |
| 643 params.player = player; | |
| 644 _proxyImpl.sendMessage(params, _mediaFactoryMethodCreatePlayerName); | |
| 645 } | |
| 646 void createSource(Object reader, List<media_types_mojom.MediaTypeSet> allowe
dMediaTypes, Object source) { | |
| 647 if (!_proxyImpl.isBound) { | |
| 648 _proxyImpl.proxyError("The Proxy is closed."); | |
| 649 return; | |
| 650 } | |
| 651 var params = new _MediaFactoryCreateSourceParams(); | |
| 652 params.reader = reader; | |
| 653 params.allowedMediaTypes = allowedMediaTypes; | |
| 654 params.source = source; | |
| 655 _proxyImpl.sendMessage(params, _mediaFactoryMethodCreateSourceName); | |
| 656 } | |
| 657 void createSink(String destinationUrl, media_types_mojom.MediaType mediaType
, Object sink) { | |
| 658 if (!_proxyImpl.isBound) { | |
| 659 _proxyImpl.proxyError("The Proxy is closed."); | |
| 660 return; | |
| 661 } | |
| 662 var params = new _MediaFactoryCreateSinkParams(); | |
| 663 params.destinationUrl = destinationUrl; | |
| 664 params.mediaType = mediaType; | |
| 665 params.sink = sink; | |
| 666 _proxyImpl.sendMessage(params, _mediaFactoryMethodCreateSinkName); | |
| 667 } | |
| 668 void createDemux(Object reader, Object demux) { | |
| 669 if (!_proxyImpl.isBound) { | |
| 670 _proxyImpl.proxyError("The Proxy is closed."); | |
| 671 return; | |
| 672 } | |
| 673 var params = new _MediaFactoryCreateDemuxParams(); | |
| 674 params.reader = reader; | |
| 675 params.demux = demux; | |
| 676 _proxyImpl.sendMessage(params, _mediaFactoryMethodCreateDemuxName); | |
| 677 } | |
| 678 void createDecoder(media_types_mojom.MediaType inputMediaType, Object decode
r) { | |
| 679 if (!_proxyImpl.isBound) { | |
| 680 _proxyImpl.proxyError("The Proxy is closed."); | |
| 681 return; | |
| 682 } | |
| 683 var params = new _MediaFactoryCreateDecoderParams(); | |
| 684 params.inputMediaType = inputMediaType; | |
| 685 params.decoder = decoder; | |
| 686 _proxyImpl.sendMessage(params, _mediaFactoryMethodCreateDecoderName); | |
| 687 } | |
| 688 void createNetworkReader(String url, Object reader) { | |
| 689 if (!_proxyImpl.isBound) { | |
| 690 _proxyImpl.proxyError("The Proxy is closed."); | |
| 691 return; | |
| 692 } | |
| 693 var params = new _MediaFactoryCreateNetworkReaderParams(); | |
| 694 params.url = url; | |
| 695 params.reader = reader; | |
| 696 _proxyImpl.sendMessage(params, _mediaFactoryMethodCreateNetworkReaderName)
; | |
| 697 } | |
| 698 } | |
| 699 | 639 |
| 640 MediaFactoryProxy.unbound() |
| 641 : super(new _MediaFactoryProxyControl.unbound()); |
| 700 | 642 |
| 701 class MediaFactoryProxy implements bindings.ProxyBase { | 643 static MediaFactoryProxy newFromEndpoint( |
| 702 final bindings.Proxy impl; | 644 core.MojoMessagePipeEndpoint endpoint) { |
| 703 MediaFactory ptr; | 645 assert(endpoint.setDescription("For MediaFactoryProxy")); |
| 704 | 646 return new MediaFactoryProxy.fromEndpoint(endpoint); |
| 705 MediaFactoryProxy(_MediaFactoryProxyImpl proxyImpl) : | |
| 706 impl = proxyImpl, | |
| 707 ptr = new _MediaFactoryProxyCalls(proxyImpl); | |
| 708 | |
| 709 MediaFactoryProxy.fromEndpoint( | |
| 710 core.MojoMessagePipeEndpoint endpoint) : | |
| 711 impl = new _MediaFactoryProxyImpl.fromEndpoint(endpoint) { | |
| 712 ptr = new _MediaFactoryProxyCalls(impl); | |
| 713 } | |
| 714 | |
| 715 MediaFactoryProxy.fromHandle(core.MojoHandle handle) : | |
| 716 impl = new _MediaFactoryProxyImpl.fromHandle(handle) { | |
| 717 ptr = new _MediaFactoryProxyCalls(impl); | |
| 718 } | |
| 719 | |
| 720 MediaFactoryProxy.unbound() : | |
| 721 impl = new _MediaFactoryProxyImpl.unbound() { | |
| 722 ptr = new _MediaFactoryProxyCalls(impl); | |
| 723 } | 647 } |
| 724 | 648 |
| 725 factory MediaFactoryProxy.connectToService( | 649 factory MediaFactoryProxy.connectToService( |
| 726 bindings.ServiceConnector s, String url, [String serviceName]) { | 650 bindings.ServiceConnector s, String url, [String serviceName]) { |
| 727 MediaFactoryProxy p = new MediaFactoryProxy.unbound(); | 651 MediaFactoryProxy p = new MediaFactoryProxy.unbound(); |
| 728 s.connectToService(url, p, serviceName); | 652 s.connectToService(url, p, serviceName); |
| 729 return p; | 653 return p; |
| 730 } | 654 } |
| 731 | 655 |
| 732 static MediaFactoryProxy newFromEndpoint( | 656 |
| 733 core.MojoMessagePipeEndpoint endpoint) { | 657 void createPlayer(Object reader, Object player) { |
| 734 assert(endpoint.setDescription("For MediaFactoryProxy")); | 658 if (!ctrl.isBound) { |
| 735 return new MediaFactoryProxy.fromEndpoint(endpoint); | 659 ctrl.proxyError("The Proxy is closed."); |
| 660 return; |
| 661 } |
| 662 var params = new _MediaFactoryCreatePlayerParams(); |
| 663 params.reader = reader; |
| 664 params.player = player; |
| 665 ctrl.sendMessage(params, |
| 666 _mediaFactoryMethodCreatePlayerName); |
| 736 } | 667 } |
| 737 | 668 void createSource(Object reader, List<media_types_mojom.MediaTypeSet> allowedM
ediaTypes, Object source) { |
| 738 String get serviceName => MediaFactory.serviceName; | 669 if (!ctrl.isBound) { |
| 739 | 670 ctrl.proxyError("The Proxy is closed."); |
| 740 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 671 return; |
| 741 | 672 } |
| 742 Future responseOrError(Future f) => impl.responseOrError(f); | 673 var params = new _MediaFactoryCreateSourceParams(); |
| 743 | 674 params.reader = reader; |
| 744 Future get errorFuture => impl.errorFuture; | 675 params.allowedMediaTypes = allowedMediaTypes; |
| 745 | 676 params.source = source; |
| 746 int get version => impl.version; | 677 ctrl.sendMessage(params, |
| 747 | 678 _mediaFactoryMethodCreateSourceName); |
| 748 Future<int> queryVersion() => impl.queryVersion(); | |
| 749 | |
| 750 void requireVersion(int requiredVersion) { | |
| 751 impl.requireVersion(requiredVersion); | |
| 752 } | 679 } |
| 753 | 680 void createSink(String destinationUrl, media_types_mojom.MediaType mediaType,
Object sink) { |
| 754 String toString() { | 681 if (!ctrl.isBound) { |
| 755 return "MediaFactoryProxy($impl)"; | 682 ctrl.proxyError("The Proxy is closed."); |
| 683 return; |
| 684 } |
| 685 var params = new _MediaFactoryCreateSinkParams(); |
| 686 params.destinationUrl = destinationUrl; |
| 687 params.mediaType = mediaType; |
| 688 params.sink = sink; |
| 689 ctrl.sendMessage(params, |
| 690 _mediaFactoryMethodCreateSinkName); |
| 691 } |
| 692 void createDemux(Object reader, Object demux) { |
| 693 if (!ctrl.isBound) { |
| 694 ctrl.proxyError("The Proxy is closed."); |
| 695 return; |
| 696 } |
| 697 var params = new _MediaFactoryCreateDemuxParams(); |
| 698 params.reader = reader; |
| 699 params.demux = demux; |
| 700 ctrl.sendMessage(params, |
| 701 _mediaFactoryMethodCreateDemuxName); |
| 702 } |
| 703 void createDecoder(media_types_mojom.MediaType inputMediaType, Object decoder)
{ |
| 704 if (!ctrl.isBound) { |
| 705 ctrl.proxyError("The Proxy is closed."); |
| 706 return; |
| 707 } |
| 708 var params = new _MediaFactoryCreateDecoderParams(); |
| 709 params.inputMediaType = inputMediaType; |
| 710 params.decoder = decoder; |
| 711 ctrl.sendMessage(params, |
| 712 _mediaFactoryMethodCreateDecoderName); |
| 713 } |
| 714 void createNetworkReader(String url, Object reader) { |
| 715 if (!ctrl.isBound) { |
| 716 ctrl.proxyError("The Proxy is closed."); |
| 717 return; |
| 718 } |
| 719 var params = new _MediaFactoryCreateNetworkReaderParams(); |
| 720 params.url = url; |
| 721 params.reader = reader; |
| 722 ctrl.sendMessage(params, |
| 723 _mediaFactoryMethodCreateNetworkReaderName); |
| 756 } | 724 } |
| 757 } | 725 } |
| 758 | 726 |
| 759 | 727 |
| 760 class MediaFactoryStub extends bindings.Stub { | 728 class MediaFactoryStub extends bindings.Stub { |
| 761 MediaFactory _impl; | 729 MediaFactory _impl; |
| 762 | 730 |
| 763 MediaFactoryStub.fromEndpoint( | 731 MediaFactoryStub.fromEndpoint( |
| 764 core.MojoMessagePipeEndpoint endpoint, [MediaFactory impl]) | 732 core.MojoMessagePipeEndpoint endpoint, [MediaFactory impl]) |
| 765 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 733 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 static service_describer.ServiceDescription get serviceDescription { | 827 static service_describer.ServiceDescription get serviceDescription { |
| 860 if (_cachedServiceDescription == null) { | 828 if (_cachedServiceDescription == null) { |
| 861 _cachedServiceDescription = new _MediaFactoryServiceDescription(); | 829 _cachedServiceDescription = new _MediaFactoryServiceDescription(); |
| 862 } | 830 } |
| 863 return _cachedServiceDescription; | 831 return _cachedServiceDescription; |
| 864 } | 832 } |
| 865 } | 833 } |
| 866 | 834 |
| 867 | 835 |
| 868 | 836 |
| OLD | NEW |