| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_MESSAGING_H_ | |
| 6 #define CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_MESSAGING_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <string> | |
| 11 | |
| 12 #include "base/strings/string_piece.h" | |
| 13 | |
| 14 // Utility functions for parsing messages from the Cast Provider to | |
| 15 // CastRemotingConnector. These have been broken-out into this separate module | |
| 16 // to allow for efficient building, linking and execution of these routines for | |
| 17 // fuzzer testing. | |
| 18 // | |
| 19 // Note: If any additions/changes are made here, please update | |
| 20 // cast_remoting_connector_fuzzertest.cc as well! | |
| 21 class CastRemotingConnectorMessaging { | |
| 22 public: | |
| 23 // Returns true if the given |message| from the Cast Provider matches the | |
| 24 // given |format| and the session ID in the |message| is equal to the | |
| 25 // |expected_session_id|. | |
| 26 static bool IsMessageForSession(const std::string& message, | |
| 27 const char* format, | |
| 28 unsigned int expected_session_id); | |
| 29 | |
| 30 // Scans |message| for |specifier| and extracts the remoting stream ID that | |
| 31 // follows the specifier. Returns a negative value on error. | |
| 32 static int32_t GetStreamIdFromStartedMessage(base::StringPiece message, | |
| 33 base::StringPiece specifier); | |
| 34 | |
| 35 // Simple command messages sent from/to the CastRemotingConnector to/from the | |
| 36 // Media Router Cast Provider to start/stop media remoting to a Cast device. | |
| 37 // | |
| 38 // Field separator (for tokenizing parts of messages). | |
| 39 static const char kMessageFieldSeparator; | |
| 40 // Message sent by CastRemotingConnector to Cast provider to start remoting. | |
| 41 // Example: | |
| 42 // "START_CAST_REMOTING:session=1f" | |
| 43 static const char kStartRemotingMessageFormat[]; | |
| 44 // Message sent by CastRemotingConnector to Cast provider to start the | |
| 45 // remoting RTP stream(s). Example: | |
| 46 // "START_CAST_REMOTING_STREAMS:session=1f:audio=N:video=Y" | |
| 47 static const char kStartStreamsMessageFormat[]; | |
| 48 // Start acknowledgement message sent by Cast provider to | |
| 49 // CastRemotingConnector once remoting RTP streams have been set up. Examples: | |
| 50 // "STARTED_CAST_REMOTING_STREAMS:session=1f:audio_stream_id=2e:" | |
| 51 // "video_stream_id=3d" | |
| 52 // "STARTED_CAST_REMOTING_STREAMS:session=1f:video_stream_id=b33f" | |
| 53 static const char kStartedStreamsMessageFormatPartial[]; | |
| 54 static const char kStartedStreamsMessageAudioIdSpecifier[]; | |
| 55 static const char kStartedStreamsMessageVideoIdSpecifier[]; | |
| 56 // Stop message sent by CastRemotingConnector to Cast provider. Example: | |
| 57 // "STOP_CAST_REMOTING:session=1f" | |
| 58 static const char kStopRemotingMessageFormat[]; | |
| 59 // Stop acknowledgement message sent by Cast provider to CastRemotingConnector | |
| 60 // once remoting is available again after the last session ended. Example: | |
| 61 // "STOPPED_CAST_REMOTING:session=1f" | |
| 62 static const char kStoppedMessageFormat[]; | |
| 63 // Failure message sent by Cast provider to CastRemotingConnector any time | |
| 64 // there was a fatal error (e.g., the Cast provider failed to set up the RTP | |
| 65 // streams, or there was some unexpected external event). Example: | |
| 66 // "FAILED_CAST_REMOTING:session=1f" | |
| 67 static const char kFailedMessageFormat[]; | |
| 68 }; | |
| 69 | |
| 70 #endif // CHROME_BROWSER_MEDIA_CAST_REMOTING_CONNECTOR_MESSAGING_H_ | |
| OLD | NEW |