Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Los clientes de reproductores multimedia pueden transmitir información valiosa a Publicación de contenido
redes (CDN) con cada solicitud de objeto. Transmitir esos datos puede mejorar la QoS
la optimización del tráfico
adaptable y el rendimiento de entrega,
y mejorar la experiencia del consumidor.
La implementación en ExoPlayer se basa en la especificación definida en
CTA‐5004.
Compatibilidad con CMCD en Exoplayer
La compatibilidad con CMCD en ExoPlayer solo se puede habilitar para formatos de transmisión adaptables,
como DASH, HLS y SmoothStreaming.
Claves de datos de CMCD
Las claves de datos de CMCD se clasifican en cuatro tipos distintos:
CMCD-Request: Claves cuyos valores varían con cada solicitud.
CMCD-Object: Claves cuyos valores varían según el objeto que se solicita.
Estado de CMCD: Claves cuyos valores no varían con cada objeto o solicitud.
Sesión de CMCD: Claves cuyos valores se espera que no varían con respecto al
la duración de la sesión.
Modos de transmisión de datos
Los datos de CMCD se pueden transmitir usando uno de estos dos métodos:
Como un encabezado de solicitud HTTP personalizado, que es el comportamiento predeterminado.
Como un argumento de consulta HTTP.
Habilitar CMCD
Para habilitar CMCD, debes crear una instancia de CmcdConfiguration.Factory
y pásalo al MediaSource.Factory, que se usa al crear la
de fútbol favorito. Puedes usar el CmcdConfiguration.Factory predeterminado o proporcionar
tu propia fábrica personalizada, a la que se llama cada vez que se crea
para el elemento multimedia determinado.
Habilita CMCD con la configuración de fábrica predeterminada
Kotlin
// Create media source factory and set default cmcdConfigurationFactory.valmediaSourceFactory=DefaultMediaSourceFactory(context).setCmcdConfigurationFactory(CmcdConfiguration.Factory.DEFAULT)
Java
// Create media source factory and set default cmcdConfigurationFactory.MediaSource.FactorymediaSourceFactory=newDefaultMediaSourceFactory(context).setCmcdConfigurationFactory(CmcdConfiguration.Factory.DEFAULT);
Habilitar CMCD con la fábrica de configuración personalizada
Kotlin
valcmcdConfigurationFactory=object:CmcdConfiguration.Factory{overridefuncreateCmcdConfiguration(mediaItem:MediaItem):CmcdConfiguration{valcmcdRequestConfig=object:CmcdConfiguration.RequestConfig{overridefunisKeyAllowed(key:String):Boolean{returnkey=="br"||key=="bl"}overridefungetCustomData():ImmutableListMultimap<@CmcdConfiguration.HeaderKeyString,String>{returnImmutableListMultimap.of(CmcdConfiguration.KEY_CMCD_OBJECT,"key1=stringValue")}overridefungetRequestedMaximumThroughputKbps(throughputKbps:Int):Int{return5*throughputKbps}}valsessionId=UUID.randomUUID().toString()valcontentId=UUID.randomUUID().toString()returnCmcdConfiguration(sessionId,contentId,cmcdRequestConfig,MODE_QUERY_PARAMETER)}}// Create media source factory and set your custom cmcdConfigurationFactory.valmediaSourceFactory=DefaultMediaSourceFactory(context).setCmcdConfigurationFactory(cmcdConfigurationFactory)
Java
CmcdConfiguration.FactorycmcdConfigurationFactory=mediaItem->{CmcdConfiguration.RequestConfigcmcdRequestConfig=newCmcdConfiguration.RequestConfig(){@OverridepublicbooleanisKeyAllowed(Stringkey){returnkey.equals("br")||key.equals("bl");}@OverridepublicImmutableListMultimap<@HeaderKeyString,String>getCustomData(){returnImmutableListMultimap.of(CmcdConfiguration.KEY_CMCD_OBJECT,"key1=stringValue");}@OverridepublicintgetRequestedMaximumThroughputKbps(intthroughputKbps){return5*throughputKbps;}};StringsessionId=UUID.randomUUID().toString();StringcontentId=UUID.randomUUID().toString();returnnewCmcdConfiguration(sessionId,contentId,cmcdRequestConfig,MODE_QUERY_PARAMETER);};// Create media source factory and set your custom cmcdConfigurationFactory.MediaSource.FactorymediaSourceFactory=newDefaultMediaSourceFactory(context).setCmcdConfigurationFactory(cmcdConfigurationFactory);
Ejemplos de datos de CMCD
Estos ejemplos ilustran combinaciones de datos válidas que se envían cuando se recuperan datos
bloques de medios:
El contenido y las muestras de código que aparecen en esta página están sujetas a las licencias que se describen en la Licencia de Contenido. Java y OpenJDK son marcas registradas de Oracle o sus afiliados.
Última actualización: 2025-07-27 (UTC)
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-07-27 (UTC)"],[],[],null,["# Common Media Client Data (CMCD)\n\nMedia player clients can transmit valuable information to Content Delivery\nNetworks (CDNs) with each object request. Transmitting that data can improve QoS\nmonitoring, adaptive traffic optimization, and delivery performance, ultimately\nenhancing the consumer experience.\n\nThe implementation in ExoPlayer is based on the specification defined in\n[CTA-5004](https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf).\n\nCMCD support in Exoplayer\n-------------------------\n\nCMCD support in ExoPlayer can only be enabled for adaptive streaming formats,\nsuch as [DASH](/guide/topics/media/exoplayer/dash), [HLS](/guide/topics/media/exoplayer/hls), and [SmoothStreaming](/guide/topics/media/exoplayer/smoothstreaming).\n\nCMCD data keys\n--------------\n\nCMCD data keys are classified into four distinct types:\n\n- **CMCD-Request**: keys whose values vary with each request.\n- **CMCD-Object**: keys whose values vary with the object being requested.\n- **CMCD-Status**: keys whose values don't vary with every request or object.\n- **CMCD-Session**: keys whose values are expected to be invariant over the life of the session.\n\nModes of transmitting data\n--------------------------\n\nCMCD data can be transmitted using one of two methods:\n\n- As a custom HTTP request header, which is the **default** behaviour.\n- As a HTTP query argument.\n\nEnable CMCD\n-----------\n\nTo enable CMCD, you need to create an instance of `CmcdConfiguration.Factory`\nand pass this to the `MediaSource.Factory` which is [used when building the\nplayer](/guide/topics/media/exoplayer/media-sources#customizing-media-source-creation). You can either use the default `CmcdConfiguration.Factory` or provide\nyour own custom factory which is called each time an adaptive media source is\ncreated for the given media item.\n\n### Enable CMCD with default configuration factory\n\n### Kotlin\n\n```kotlin\n// Create media source factory and set default cmcdConfigurationFactory.\nval mediaSourceFactory =\n DefaultMediaSourceFactory(context)\n .setCmcdConfigurationFactory(CmcdConfiguration.Factory.DEFAULT)\n```\n\n### Java\n\n```java\n// Create media source factory and set default cmcdConfigurationFactory.\nMediaSource.Factory mediaSourceFactory =\n new DefaultMediaSourceFactory(context)\n .setCmcdConfigurationFactory(CmcdConfiguration.Factory.DEFAULT);\n```\n\n\u003cbr /\u003e\n\n| **Note:** When using the default configuration, data is transmitted as custom HTTP request headers.\n\n### Enable CMCD with custom configuration factory\n\n### Kotlin\n\n```kotlin\nval cmcdConfigurationFactory = object : CmcdConfiguration.Factory {\n override fun createCmcdConfiguration(mediaItem: MediaItem): CmcdConfiguration {\n val cmcdRequestConfig = object : CmcdConfiguration.RequestConfig {\n override fun isKeyAllowed(key: String): Boolean {\n return key == \"br\" || key == \"bl\"\n }\n\n override fun getCustomData(): ImmutableListMultimap\u003c@CmcdConfiguration.HeaderKey String, String\u003e {\n return ImmutableListMultimap.of(\n CmcdConfiguration.KEY_CMCD_OBJECT, \"key1=stringValue\")\n }\n\n override fun getRequestedMaximumThroughputKbps(throughputKbps: Int): Int {\n return 5 * throughputKbps\n }\n }\n\n val sessionId = UUID.randomUUID().toString()\n val contentId = UUID.randomUUID().toString()\n\n return CmcdConfiguration(sessionId, contentId, cmcdRequestConfig, MODE_QUERY_PARAMETER)\n }\n}\n\n// Create media source factory and set your custom cmcdConfigurationFactory.\nval mediaSourceFactory =\n DefaultMediaSourceFactory(context)\n .setCmcdConfigurationFactory(cmcdConfigurationFactory)\n```\n\n### Java\n\n```java\nCmcdConfiguration.Factory cmcdConfigurationFactory = mediaItem -\u003e {\n CmcdConfiguration.RequestConfig cmcdRequestConfig = new CmcdConfiguration.RequestConfig() {\n @Override\n public boolean isKeyAllowed(String key) {\n return key.equals(\"br\") || key.equals(\"bl\");\n }\n\n @Override\n public ImmutableListMultimap\u003c@HeaderKey String, String\u003e getCustomData() {\n return ImmutableListMultimap.of(\n CmcdConfiguration.KEY_CMCD_OBJECT, \"key1=stringValue\");\n }\n\n @Override\n public int getRequestedMaximumThroughputKbps(int throughputKbps) {\n return 5 * throughputKbps;\n }\n };\n\n String sessionId = UUID.randomUUID().toString();\n String contentId = UUID.randomUUID().toString();\n\n return new CmcdConfiguration(sessionId, contentId, cmcdRequestConfig, MODE_QUERY_PARAMETER);\n};\n\n// Create media source factory and set your custom cmcdConfigurationFactory.\nMediaSource.Factory mediaSourceFactory =\n new DefaultMediaSourceFactory(context)\n .setCmcdConfigurationFactory(cmcdConfigurationFactory);\n```\n\n\u003cbr /\u003e\n\n| **Note:** When utilising a custom configuration, you have the option to transmit data as custom request headers (`MODE_REQUEST_HEADER`) or as query parameters (`MODE_QUERY_PARAMETER`).\n\nCMCD data examples\n------------------\n\nThese examples illustrate valid data combinations of data sent when fetching\nmedia chunks:\n\n- As custom HTTP request headers\n\n CMCD-Session:sid=\"6e2fb550-c457-11e9-bb97-0800200c9a66\"\n\n CMCD-Request:mtp=25400 CMCD-Object:br=3200,d=4004,ot=v,tb=6000\n CMCD-Status:bs,rtp=15000\n CMCD-Session:sid=\"6e2fb550-c457-11e9-bb97-0800200c9a66\"\n\n- As HTTP query arguments\n\n ?CMCD=sid%3D%226e2fb550-c457-11e9-bb97-0800200c9a66%22\n\n ?CMCD=br%3D3200%2Cbs%2Cd%3D4004%2Cmtp%3D25400%2Cot%3Dv%2Crtp\n %3D15000%2Csid%3D%226e2fb550-c457-11e9-bb97-\n 0800200c9a66%22%2Ctb%3D6000"]]