| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebMIDIAccessorClient_h | 31 #ifndef WebMIDIAccessorClient_h |
| 32 #define WebMIDIAccessorClient_h | 32 #define WebMIDIAccessorClient_h |
| 33 | 33 |
| 34 #include "media/midi/midi_service.mojom-shared.h" |
| 34 #include "public/platform/WebString.h" | 35 #include "public/platform/WebString.h" |
| 35 | 36 |
| 36 namespace blink { | 37 namespace blink { |
| 37 | 38 |
| 38 class WebMIDIAccessorClient { | 39 class WebMIDIAccessorClient { |
| 39 public: | 40 public: |
| 40 enum MIDIPortState { | 41 enum MIDIPortState { |
| 41 MIDIPortStateDisconnected, | 42 MIDIPortStateDisconnected, |
| 42 MIDIPortStateConnected, | 43 MIDIPortStateConnected, |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 // didAddInputPort() and didAddOutputPort() can be called before and after | 46 // didAddInputPort() and didAddOutputPort() can be called before and after |
| 46 // didStartSession() is called. But |id| should be unique in each function. | 47 // didStartSession() is called. But |id| should be unique in each function. |
| 47 virtual void didAddInputPort(const WebString& id, | 48 virtual void didAddInputPort(const WebString& id, |
| 48 const WebString& manufacturer, | 49 const WebString& manufacturer, |
| 49 const WebString& name, | 50 const WebString& name, |
| 50 const WebString& version, | 51 const WebString& version, |
| 51 MIDIPortState) = 0; | 52 MIDIPortState) = 0; |
| 52 virtual void didAddOutputPort(const WebString& id, | 53 virtual void didAddOutputPort(const WebString& id, |
| 53 const WebString& manufacturer, | 54 const WebString& manufacturer, |
| 54 const WebString& name, | 55 const WebString& name, |
| 55 const WebString& version, | 56 const WebString& version, |
| 56 MIDIPortState) = 0; | 57 MIDIPortState) = 0; |
| 57 // didSetInputPortState() and didSetOutputPortState() should not be called | 58 // didSetInputPortState() and didSetOutputPortState() should not be called |
| 58 // until didStartSession() is called. | 59 // until didStartSession() is called. |
| 59 virtual void didSetInputPortState(unsigned portIndex, MIDIPortState) = 0; | 60 virtual void didSetInputPortState(unsigned portIndex, MIDIPortState) = 0; |
| 60 virtual void didSetOutputPortState(unsigned portIndex, MIDIPortState) = 0; | 61 virtual void didSetOutputPortState(unsigned portIndex, MIDIPortState) = 0; |
| 61 | 62 |
| 62 virtual void didStartSession(bool success, | 63 virtual void didStartSession(midi::mojom::Result) = 0; |
| 63 const WebString& error, | |
| 64 const WebString& message) = 0; | |
| 65 | 64 |
| 66 // |timeStamp| is in milliseconds according to the Web MIDI API. | 65 // |timeStamp| is in milliseconds according to the Web MIDI API. |
| 67 virtual void didReceiveMIDIData(unsigned portIndex, | 66 virtual void didReceiveMIDIData(unsigned portIndex, |
| 68 const unsigned char* data, | 67 const unsigned char* data, |
| 69 size_t length, | 68 size_t length, |
| 70 double timeStamp) = 0; | 69 double timeStamp) = 0; |
| 71 | 70 |
| 72 protected: | 71 protected: |
| 73 virtual ~WebMIDIAccessorClient() {} | 72 virtual ~WebMIDIAccessorClient() {} |
| 74 }; | 73 }; |
| 75 | 74 |
| 76 } // namespace blink | 75 } // namespace blink |
| 77 | 76 |
| 78 #endif // WebMIDIAccessorClient_h | 77 #endif // WebMIDIAccessorClient_h |
| OLD | NEW |