1 // Copyright (c) 2012 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.
5 // Multiply-included message file, hence no include guard.
9 #include "base/memory/shared_memory.h"
10 #include "base/sync_socket.h"
11 #include "content/public/common/speech_recognition_error.h"
12 #include "content/public/common/speech_recognition_grammar.h"
13 #include "content/public/common/speech_recognition_result.h"
14 #include "ipc/ipc_message_macros.h"
15 #include "ipc/ipc_param_traits.h"
16 #include "media/audio/audio_parameters.h"
17 #include "ui/gfx/rect.h"
19 #define IPC_MESSAGE_START SpeechRecognitionMsgStart
21 IPC_ENUM_TRAITS_MAX_VALUE(content::SpeechAudioErrorDetails
,
22 content::SPEECH_AUDIO_ERROR_DETAILS_LAST
)
23 IPC_ENUM_TRAITS_MAX_VALUE(content::SpeechRecognitionErrorCode
,
24 content::SPEECH_RECOGNITION_ERROR_LAST
)
26 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionError
)
27 IPC_STRUCT_TRAITS_MEMBER(code
)
28 IPC_STRUCT_TRAITS_MEMBER(details
)
29 IPC_STRUCT_TRAITS_END()
31 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionHypothesis
)
32 IPC_STRUCT_TRAITS_MEMBER(utterance
)
33 IPC_STRUCT_TRAITS_MEMBER(confidence
)
34 IPC_STRUCT_TRAITS_END()
36 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionResult
)
37 IPC_STRUCT_TRAITS_MEMBER(is_provisional
)
38 IPC_STRUCT_TRAITS_MEMBER(hypotheses
)
39 IPC_STRUCT_TRAITS_END()
41 IPC_STRUCT_TRAITS_BEGIN(content::SpeechRecognitionGrammar
)
42 IPC_STRUCT_TRAITS_MEMBER(url
)
43 IPC_STRUCT_TRAITS_MEMBER(weight
)
44 IPC_STRUCT_TRAITS_END()
46 // ------- Messages for Speech JS APIs (SpeechRecognitionDispatcher) ----------
48 // Renderer -> Browser messages.
50 // Used to start a speech recognition session.
51 IPC_STRUCT_BEGIN(SpeechRecognitionHostMsg_StartRequest_Params
)
52 // The render view requesting speech recognition.
53 IPC_STRUCT_MEMBER(int, render_view_id
)
54 // Unique ID associated with the JS object making the calls.
55 IPC_STRUCT_MEMBER(int, request_id
)
56 // Language to use for speech recognition.
57 IPC_STRUCT_MEMBER(std::string
, language
)
58 // Speech grammars to use.
59 IPC_STRUCT_MEMBER(content::SpeechRecognitionGrammarArray
, grammars
)
60 // URL of the page (or iframe if applicable).
61 IPC_STRUCT_MEMBER(std::string
, origin_url
)
62 // Maximum number of hypotheses allowed for each results.
63 IPC_STRUCT_MEMBER(uint32
, max_hypotheses
)
64 // Whether the user requested continuous recognition or not.
65 IPC_STRUCT_MEMBER(bool, continuous
)
66 // Whether the user requested interim results or not.
67 IPC_STRUCT_MEMBER(bool, interim_results
)
68 // Wheter the user has set an audio track as input or not.
69 IPC_STRUCT_MEMBER(bool, using_audio_track
)
73 // Requests the speech recognition service to start speech recognition.
74 IPC_MESSAGE_CONTROL1(SpeechRecognitionHostMsg_StartRequest
,
75 SpeechRecognitionHostMsg_StartRequest_Params
)
77 // Requests the speech recognition service to abort speech recognition on
78 // behalf of the given |render_view_id| and |request_id|. If there are no
79 // sessions associated with the |request_id| in the render view, this call
81 IPC_MESSAGE_CONTROL2(SpeechRecognitionHostMsg_AbortRequest
,
82 int /* render_view_id */,
85 // Requests the speech recognition service to abort all speech recognitions on
86 // behalf of the given |render_view_id|. If speech recognition is not happening
87 // or is happening on behalf of some other render view, this call does nothing.
88 IPC_MESSAGE_CONTROL1(SpeechRecognitionHostMsg_AbortAllRequests
,
89 int /* render_view_id */)
91 // Requests the speech recognition service to stop audio capture on behalf of
92 // the given |render_view_id|. Any audio recorded so far will be fed to the
93 // speech recognizer. If speech recognition is not happening nor or is
94 // happening on behalf of some other render view, this call does nothing.
95 IPC_MESSAGE_CONTROL2(SpeechRecognitionHostMsg_StopCaptureRequest
,
96 int /* render_view_id */,
99 // Browser -> Renderer messages.
101 // The messages below follow exactly the same semantic of the corresponding
102 // events defined in content/public/browser/speech_recognition_event_listener.h.
103 IPC_MESSAGE_ROUTED2(SpeechRecognitionMsg_ResultRetrieved
,
104 int /* request_id */,
105 content::SpeechRecognitionResults
/* results */)
107 IPC_MESSAGE_ROUTED2(SpeechRecognitionMsg_ErrorOccurred
,
108 int /* request_id */,
109 content::SpeechRecognitionError
/* error */)
111 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_Started
, int /* request_id */)
113 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_AudioStarted
, int /* request_id */)
115 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_SoundStarted
, int /* request_id */)
117 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_SoundEnded
, int /* request_id */)
119 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_AudioEnded
, int /* request_id */)
121 IPC_MESSAGE_ROUTED1(SpeechRecognitionMsg_Ended
, int /* request_id */)
123 IPC_MESSAGE_ROUTED4(SpeechRecognitionMsg_AudioReceiverReady
,
124 int /* request_id */,
125 media::AudioParameters
/* params */,
126 base::SharedMemoryHandle
/* memory */,
127 base::SyncSocket::TransitDescriptor
/* socket */)