Dados comuns do cliente de mídia (CMCD, na sigla em inglês)
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Os clientes de player de mídia podem transmitir informações valiosas para o Envio de conteúdo
Redes (CDNs) com cada solicitação de objeto. A transmissão desses dados pode melhorar o QoS
monitoramento, otimização de tráfego adaptável e desempenho de exibição,
melhorando a experiência do consumidor.
A implementação no ExoPlayer é baseada na especificação definida em
CTA-5004.
Compatibilidade com CMCD no Exoplayer
A compatibilidade com CMCD no ExoPlayer só pode ser ativada para formatos de streaming adaptáveis,
como DASH, HLS e SmoothStreaming.
Chaves de dados CMCD
As chaves de dados CMCD são classificadas em quatro tipos distintos:
CMCD-Request: chaves com valores que variam de acordo com a solicitação.
CMCD-Object: chaves com valores que variam de acordo com o objeto solicitado.
CMCD-Status: chaves com valores que não variam a cada solicitação ou objeto.
CMCD-Session: chaves com valores que se espera que sejam invariantes na
vida útil da sessão.
Modos de transmissão de dados
Os dados CMCD podem ser transmitidos usando um destes dois métodos:
Como um cabeçalho de solicitação HTTP personalizado, que é o comportamento padrão.
Como um argumento de consulta HTTP.
Ativar CMCD
Para ativar o CMCD, é preciso criar uma instância de CmcdConfiguration.Factory
e a passamos para o MediaSource.Factory, que é usado ao criar o
player de vídeo. É possível usar o CmcdConfiguration.Factory padrão ou fornecer
sua própria fábrica personalizada, que é chamada sempre que uma origem de mídia adaptável é
criado para determinado item de mídia.
Ativar o CMCD com a fábrica de configuração padrão
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);
Ativar CMCD com fábrica de configuração 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);
Exemplos de dados CMCD
Os exemplos ilustram combinações válidas de dados enviados ao fazer a busca
blocos de mídia:
Como cabeçalhos de solicitação HTTP personalizados
O conteúdo e os exemplos de código nesta página estão sujeitos às licenças descritas na Licença de conteúdo. Java e OpenJDK são marcas registradas da Oracle e/ou suas afiliadas.
Última atualização 2025-07-27 UTC.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 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"]]