mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	Add CefMediaSink::GetIconType (see issue #2900)
This attribute is useful for identifying different classes of cast devices without first requiring a connection (CAST, CAST_AUDIO, CAST_AUDIO_GROUP, etc).
This commit is contained in:
		| @@ -33,7 +33,7 @@ | ||||
| // by hand. See the translator.README.txt file in the tools directory for | ||||
| // more information. | ||||
| // | ||||
| // $hash=a7070419332ec8f6d6e4df898c8eb666b988970a$ | ||||
| // $hash=aa1310919932145744d5347d449d6ee10a3a0813$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_INCLUDE_CAPI_CEF_MEDIA_ROUTER_CAPI_H_ | ||||
| @@ -264,6 +264,12 @@ typedef struct _cef_media_sink_t { | ||||
|   cef_string_userfree_t(CEF_CALLBACK* get_description)( | ||||
|       struct _cef_media_sink_t* self); | ||||
|  | ||||
|   /// | ||||
|   // Returns the icon type for this sink. | ||||
|   /// | ||||
|   cef_media_sink_icon_type_t(CEF_CALLBACK* get_icon_type)( | ||||
|       struct _cef_media_sink_t* self); | ||||
|  | ||||
|   /// | ||||
|   // Returns true (1) if this sink accepts content via Cast. | ||||
|   /// | ||||
|   | ||||
| @@ -34,7 +34,7 @@ | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=af15b08731cc133c3974ceb18002b146a53b9c9e$ | ||||
| // $hash=fd013f5bdcf2333b1f0fb452442d300dffe598e5$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_INCLUDE_API_HASH_H_ | ||||
| @@ -47,13 +47,13 @@ | ||||
| // way that may cause binary incompatibility with other builds. The universal | ||||
| // hash value will change if any platform is affected whereas the platform hash | ||||
| // values will change only if that particular platform is affected. | ||||
| #define CEF_API_HASH_UNIVERSAL "f76dc8c40e454ef26318d0f83312dadaf909e4c5" | ||||
| #define CEF_API_HASH_UNIVERSAL "c80d4c5f1dc72279ac7a44d7b174fb80cf728abc" | ||||
| #if defined(OS_WIN) | ||||
| #define CEF_API_HASH_PLATFORM "831ef33853bb8575bcd097ba65851d4d98a08db8" | ||||
| #define CEF_API_HASH_PLATFORM "bde71fdc88914ed7353ee7308d060cd6b4f8c8af" | ||||
| #elif defined(OS_MACOSX) | ||||
| #define CEF_API_HASH_PLATFORM "0944363458590a23d84e99eb1b81372be6784b97" | ||||
| #define CEF_API_HASH_PLATFORM "2fb3e42a6d2e594aa55792b5852d7f57524ab011" | ||||
| #elif defined(OS_LINUX) | ||||
| #define CEF_API_HASH_PLATFORM "dfd012193a93782cd4b041f4cd71e1e8f2ca401e" | ||||
| #define CEF_API_HASH_PLATFORM "222824f83536a111c6480dba64833251c01cd6fd" | ||||
| #endif | ||||
|  | ||||
| #ifdef __cplusplus | ||||
|   | ||||
| @@ -221,6 +221,8 @@ class CefMediaRouteCreateCallback : public virtual CefBaseRefCounted { | ||||
| /*--cef(source=library)--*/ | ||||
| class CefMediaSink : public virtual CefBaseRefCounted { | ||||
|  public: | ||||
|   typedef cef_media_sink_icon_type_t IconType; | ||||
|  | ||||
|   /// | ||||
|   // Returns the ID for this sink. | ||||
|   /// | ||||
| @@ -245,6 +247,12 @@ class CefMediaSink : public virtual CefBaseRefCounted { | ||||
|   /*--cef()--*/ | ||||
|   virtual CefString GetDescription() = 0; | ||||
|  | ||||
|   /// | ||||
|   // Returns the icon type for this sink. | ||||
|   /// | ||||
|   /*--cef(default_retval=CEF_MSIT_GENERIC)--*/ | ||||
|   virtual IconType GetIconType() = 0; | ||||
|  | ||||
|   /// | ||||
|   // Returns true if this sink accepts content via Cast. | ||||
|   /// | ||||
|   | ||||
| @@ -3004,9 +3004,8 @@ typedef struct _cef_composition_underline_t { | ||||
| } cef_composition_underline_t; | ||||
|  | ||||
| /// | ||||
| // Result codes for CefMediaRouter::CreateRoute. These constants match | ||||
| // their equivalents in Chromium's route_request_result.h and should not be | ||||
| // renumbered. | ||||
| // Result codes for CefMediaRouter::CreateRoute. Should be kept in sync with | ||||
| // Chromium's media_router::RouteRequestResult::ResultCode type. | ||||
| /// | ||||
| typedef enum { | ||||
|   CEF_MRCR_UNKNOWN_ERROR = 0, | ||||
| @@ -3033,6 +3032,23 @@ typedef enum { | ||||
|   CEF_MRCS_TERMINATED, | ||||
| } cef_media_route_connection_state_t; | ||||
|  | ||||
| /// | ||||
| // Icon types for a MediaSink object. Should be kept in sync with Chromium's | ||||
| // media_router::SinkIconType type. | ||||
| /// | ||||
| typedef enum { | ||||
|   CEF_MSIT_CAST, | ||||
|   CEF_MSIT_CAST_AUDIO_GROUP, | ||||
|   CEF_MSIT_CAST_AUDIO, | ||||
|   CEF_MSIT_MEETING, | ||||
|   CEF_MSIT_HANGOUT, | ||||
|   CEF_MSIT_EDUCATION, | ||||
|   CEF_MSIT_WIRED_DISPLAY, | ||||
|   CEF_MSIT_GENERIC, | ||||
|  | ||||
|   CEF_MSIT_TOTAL_COUNT,  // The total number of values. | ||||
| } cef_media_sink_icon_type_t; | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
|   | ||||
| @@ -27,6 +27,15 @@ CefString CefMediaSinkImpl::GetDescription() { | ||||
|   return sink_.description().value_or(""); | ||||
| } | ||||
|  | ||||
| CefMediaSink::IconType CefMediaSinkImpl::GetIconType() { | ||||
|   // Verify that our enum matches Chromium's values. | ||||
|   static_assert(static_cast<int>(CEF_MSIT_TOTAL_COUNT) == | ||||
|                     static_cast<int>(media_router::SinkIconType::TOTAL_COUNT), | ||||
|                 "enum mismatch"); | ||||
|  | ||||
|   return static_cast<CefMediaSink::IconType>(sink_.icon_type()); | ||||
| } | ||||
|  | ||||
| bool CefMediaSinkImpl::IsCastSink() { | ||||
|   return sink_.provider_id() == media_router::CAST; | ||||
| } | ||||
|   | ||||
| @@ -22,6 +22,7 @@ class CefMediaSinkImpl : public CefMediaSink { | ||||
|   bool IsValid() override; | ||||
|   CefString GetName() override; | ||||
|   CefString GetDescription() override; | ||||
|   IconType GetIconType() override; | ||||
|   bool IsCastSink() override; | ||||
|   bool IsDialSink() override; | ||||
|   bool IsCompatibleWith(CefRefPtr<CefMediaSource> source) override; | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=cbbac244f39cc1d644b0db80a3f7234399286368$ | ||||
| // $hash=3a295e7d6703e2e8effd94da8e97d8b7f451dc32$ | ||||
| // | ||||
|  | ||||
| #include "libcef_dll/cpptoc/media_sink_cpptoc.h" | ||||
| @@ -87,6 +87,24 @@ media_sink_get_description(struct _cef_media_sink_t* self) { | ||||
|   return _retval.DetachToUserFree(); | ||||
| } | ||||
|  | ||||
| cef_media_sink_icon_type_t CEF_CALLBACK | ||||
| media_sink_get_icon_type(struct _cef_media_sink_t* self) { | ||||
|   shutdown_checker::AssertNotShutdown(); | ||||
|  | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   DCHECK(self); | ||||
|   if (!self) | ||||
|     return CEF_MSIT_GENERIC; | ||||
|  | ||||
|   // Execute | ||||
|   cef_media_sink_icon_type_t _retval = | ||||
|       CefMediaSinkCppToC::Get(self)->GetIconType(); | ||||
|  | ||||
|   // Return type: simple | ||||
|   return _retval; | ||||
| } | ||||
|  | ||||
| int CEF_CALLBACK media_sink_is_cast_sink(struct _cef_media_sink_t* self) { | ||||
|   shutdown_checker::AssertNotShutdown(); | ||||
|  | ||||
| @@ -151,6 +169,7 @@ CefMediaSinkCppToC::CefMediaSinkCppToC() { | ||||
|   GetStruct()->is_valid = media_sink_is_valid; | ||||
|   GetStruct()->get_name = media_sink_get_name; | ||||
|   GetStruct()->get_description = media_sink_get_description; | ||||
|   GetStruct()->get_icon_type = media_sink_get_icon_type; | ||||
|   GetStruct()->is_cast_sink = media_sink_is_cast_sink; | ||||
|   GetStruct()->is_dial_sink = media_sink_is_dial_sink; | ||||
|   GetStruct()->is_compatible_with = media_sink_is_compatible_with; | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=bb39ec5e546482b707c1e01a83fc1b064d96a4e6$ | ||||
| // $hash=63071af2d949b451ad0e7273ca0f5d7bfec425db$ | ||||
| // | ||||
|  | ||||
| #include "libcef_dll/ctocpp/media_sink_ctocpp.h" | ||||
| @@ -88,6 +88,23 @@ NO_SANITIZE("cfi-icall") CefString CefMediaSinkCToCpp::GetDescription() { | ||||
|   return _retvalStr; | ||||
| } | ||||
|  | ||||
| NO_SANITIZE("cfi-icall") | ||||
| CefMediaSink::IconType CefMediaSinkCToCpp::GetIconType() { | ||||
|   shutdown_checker::AssertNotShutdown(); | ||||
|  | ||||
|   cef_media_sink_t* _struct = GetStruct(); | ||||
|   if (CEF_MEMBER_MISSING(_struct, get_icon_type)) | ||||
|     return CEF_MSIT_GENERIC; | ||||
|  | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   // Execute | ||||
|   cef_media_sink_icon_type_t _retval = _struct->get_icon_type(_struct); | ||||
|  | ||||
|   // Return type: simple | ||||
|   return _retval; | ||||
| } | ||||
|  | ||||
| NO_SANITIZE("cfi-icall") bool CefMediaSinkCToCpp::IsCastSink() { | ||||
|   shutdown_checker::AssertNotShutdown(); | ||||
|  | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=d69c0bdadc802bc7cb970c316f3a0ed8529c5f9c$ | ||||
| // $hash=c57a82e66fdcd26f70a69fbd92554ca8aa38495c$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_LIBCEF_DLL_CTOCPP_MEDIA_SINK_CTOCPP_H_ | ||||
| @@ -38,6 +38,7 @@ class CefMediaSinkCToCpp : public CefCToCppRefCounted<CefMediaSinkCToCpp, | ||||
|   bool IsValid() OVERRIDE; | ||||
|   CefString GetName() OVERRIDE; | ||||
|   CefString GetDescription() OVERRIDE; | ||||
|   IconType GetIconType() OVERRIDE; | ||||
|   bool IsCastSink() OVERRIDE; | ||||
|   bool IsDialSink() OVERRIDE; | ||||
|   bool IsCompatibleWith(CefRefPtr<CefMediaSource> source) OVERRIDE; | ||||
|   | ||||
| @@ -161,6 +161,7 @@ class MediaObserver : public CefMediaObserver { | ||||
|       sink_dict->SetString("id", sink_id); | ||||
|       sink_dict->SetString("name", sink->GetName()); | ||||
|       sink_dict->SetString("desc", sink->GetDescription()); | ||||
|       sink_dict->SetInt("icon", sink->GetIconType()); | ||||
|       sink_dict->SetString( | ||||
|           "type", sink->IsCastSink() ? "cast" | ||||
|                                      : sink->IsDialSink() ? "dial" : "unknown"); | ||||
|   | ||||
| @@ -112,6 +112,32 @@ function getStateLabel(state) { | ||||
|   return "UNKNOWN"; | ||||
| } | ||||
|  | ||||
| // Values from cef_media_sink_icon_type_t. | ||||
| var CEF_MSIT_CAST = 0; | ||||
| var CEF_MSIT_CAST_AUDIO_GROUP = 1; | ||||
| var CEF_MSIT_CAST_AUDIO = 2; | ||||
| var CEF_MSIT_MEETING = 3; | ||||
| var CEF_MSIT_HANGOUT = 4; | ||||
| var CEF_MSIT_EDUCATION = 5; | ||||
| var CEF_MSIT_WIRED_DISPLAY = 6; | ||||
| var CEF_MSIT_GENERIC = 7; | ||||
|  | ||||
| function getIconTypeLabel(type) { | ||||
|   switch (type) { | ||||
|     case CEF_MSIT_CAST: return "CAST"; | ||||
|     case CEF_MSIT_CAST_AUDIO_GROUP: return "CAST_AUDIO_GROUP"; | ||||
|     case CEF_MSIT_CAST_AUDIO: return "CAST_AUDIO"; | ||||
|     case CEF_MSIT_MEETING: return "MEETING"; | ||||
|     case CEF_MSIT_HANGOUT: return "HANGOUT"; | ||||
|     case CEF_MSIT_EDUCATION: return "EDUCATION"; | ||||
|     case CEF_MSIT_WIRED_DISPLAY: return "WIRED_DISPLAY"; | ||||
|     case CEF_MSIT_GENERIC: return "GENERIC"; | ||||
|     default: break; | ||||
|   } | ||||
|   return "UNKNOWN"; | ||||
| } | ||||
|  | ||||
|  | ||||
| /// | ||||
| // Manage show/hide of default text for form elements. | ||||
| /// | ||||
| @@ -213,7 +239,9 @@ Expected format for |sinks| is: | ||||
|     { | ||||
|       name: string, | ||||
|       type: string ('cast' or 'dial'), | ||||
|       id: string | ||||
|       id: string, | ||||
|       desc: string, | ||||
|       icon: int | ||||
|     }, ... | ||||
|   ] | ||||
| */ | ||||
| @@ -248,7 +276,7 @@ function updateSinks(sinks) { | ||||
|     if (oldValues.includes(sink.id)) | ||||
|       continue; | ||||
|     var opt = document.createElement('option'); | ||||
|     opt.innerHTML = sink.name + ' (' + sink.type + ')'; | ||||
|     opt.innerHTML = sink.name + ' (' + sink.type + ', ' + getIconTypeLabel(sink.icon) + ')'; | ||||
|     opt.value = sink.id; | ||||
|     sinksSelect.appendChild(opt); | ||||
|   } | ||||
| @@ -476,12 +504,16 @@ function initDemoMode() { | ||||
|     { | ||||
|       name: 'Sink 1', | ||||
|       type: 'cast', | ||||
|       id: 'sink1' | ||||
|       id: 'sink1', | ||||
|       desc: 'My cast device', | ||||
|       icon: CEF_MSIT_CAST | ||||
|     }, | ||||
|     { | ||||
|       name: 'Sink 2', | ||||
|       type: 'dial', | ||||
|       id: 'sink2' | ||||
|       id: 'sink2', | ||||
|       desc: 'My dial device', | ||||
|       icon: CEF_MSIT_GENERIC | ||||
|     } | ||||
|   ]; | ||||
|   updateSinks(sinks); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user