SlideShare uma empresa Scribd logo
1 de 16
옆에 보이는 그림은 안드로이드 내에서 동영상을 재생하는 화면입니다.
표면적으로 View라는 클래스에 내부적으로 MediaPlayer라는 클래스
가 렌더링하도록 도와줍니다.
도식적으로 나타내면 아래와 같이 화면 View 뒤에서 MediaPlayer가
있는 개념입니다.

View

MediaPlayer
MediaPlayer는
http://developer.android.com/reference/android/media/MediaPlayer.html
위 주소에 class spec이 나와있습니다.
Instance 생성 후
setDataSource()를 통해 어디서 비디오 데이터를
가져올 것인지 source를 설정해줍니다.
Android Version 3.0 HoneyComb 이후 HLS에서
가져올 수 있기 때문에
setDataSource(“http://~~~address.m3u8”);
이런 식으로 적어주면 작동합니다.
MediaPlayer.java는
https://code.google.com/p/android-sourcebrowsing/source/browse/media/java/android/media/MediaPlayer.java?repo=platform-frameworks--base&name=android-4.0.1_r1
여기서 소스를 볼 수 있습니다.
아까 setDataSource(“http://~~~address.m3u8”); 이런 명령을 내렸으니까

위의 Method를 찾아가게 됩니다.
Native라고 붙었는데 이것은 java 자체에서 해결되는 function이 아니라 C/C++ 소스와 연결되어
있다는 겁니다. Inteface method처럼 구현된 부분은 java파일에 없습니다.
MediaPlayer.java 내부에 위와 같이 media_jni를 로드하겠다는 static 명령이 있습니다.
이것은 libmedia_jni.so 파일을 로드하겠다는건데 이파일은 C/C++을 컴파일 한겁니다.
https://code.google.com/p/android-sourcebrowsing/source/browse/media/?repo=platform--frameworks--base&name=android4.0.1_r1#media%2Fjni
-다음장~
컴파일할 cpp목록

위 주소로 가면 Android.mk 파일이 있는데
이를 열어보면 좌측과 같습니다.

이파일은 안드로이드 자체에서 쓰고 있는 일종의 makefile
인데 이것을 이용해서 make하면
Media/jni의 디렉토리에 있는 것들이 모두 libmedia_jni.so
Include에서 쓰이는 library들 로 컴파일 됩니다.
(shared)
그래서 아까의 native functio과 같이 java와 연결되어
C/C++ function에 접근 할 수 있습니다.

Include에서 쓰이는 library들
(static)

Library 파일 이름
Android_media_MediaPlayer.cpp
https://code.google.com/p/android-sourcebrowsing/source/browse/media/jni/android_media_MediaPlayer.cpp?repo=platform-frameworks--base&name=android-4.0.1_r1
이 파일을 보면

위와 같이 java에서의 setDataSource(String…)을 Android_media_MediaPlayer_setDataSource()
에 function pointer로 연결하고 있습니다. android_media_MediaPlayer_setDataSource
그래서 android_media_MediaPlayer_serDataSource()를 찾아가면 위와 같고
다시 android_media_MediaPlayer_setDataSource
AndHeaders()를 찾아가면 좌측과 같습니다.
sp<MediaPlayer> mp
: sp는 스마트 포인터고 MediaPlayer는 C/C++ level의
MediaPlayer Class입니다.
이전에 instance화 했던 mediaPlayer를 불러오는 것.

아까 Java에서 MediaPlayer의 datasource로 주었던
path가 C/C++의 mediaPlayer로 전달됩니다.
Mediaplayer.cpp 파일은 media/libmedia/ 디렉토리에 있고
https://code.google.com/p/android-source-browsing/source/browse/media
/?repo=platform--frameworks--base&name=android-4.0.1_r1#media%2Flibmedia
위 주소로 가면 볼 수 있습니다.

그 안에 setDataSource()가 있고 IMediaPlayerService를 통해 IMediaPlayer type의
player를 만듭니다.
IMediaPlayerService와 IMediaPlayer는 MediaPlayerService, MediaPlayer의 proxy
class입니다.
/include/media/
https://code.google.com/p/android-source-browsing/source/browse/
?repo=platform--frameworks--base&name=android-4.0.3_r1#git%2Finclude%2Fmedia
에가면 IMediaPlayerService.h와 IMediaPlayer.h를 볼 수 있는데

위와 같이 각각 MediaPlayerService class와 MediaPlayer class에 연결되는걸 볼 수 있습니다.
DECLARE_META_INTERFACE는 안드로이드에서 정의한 매크로로 proxy class와 원래 class를 연결해 줍니다.
8p의 148line에서 IMediaPlayerService instance service의 create를 실행하는데
이를 보기 위해 MediaPlayerService.cpp를 보아야 합니다.
https://code.google.com/p/android-source-browsing/source/browse/media/
libmediaplayerservice/MediaPlayerService.cpp?repo=platform--frameworks--base&name=android-4.0.3_r1

MediaPlayerService::creat는 265line에서 생성된 Client를 retur하는데
Client Class는 MediaPlayerService.h에 정의돼있고 MediaPlayerService.cpp에 구현돼있습니다.
8p의 148line에서 IMediaPlayerService instance service의 create를 실행하는데
이를 보기 위해 MediaPlayerService.cpp를 보아야 합니다.
https://code.google.com/p/android-source-browsing/source/browse/media/
libmediaplayerservice/MediaPlayerService.cpp?repo=platform--frameworks--base&name=android-4.0.3_r1

MediaPlayerService::creat는 265line에서 생성된 Client를 retur하는데
Client Class는 MediaPlayerService.h에 정의돼있고 MediaPlayerService.cpp에 구현돼있습니다.
결국 8p 149line에서 player->setDataSource()는 MediaPlayerService.cpp안에 구현된
Client::setDataSource()를 가리키게 됩니다.
https://code.google.com/p/android-source-browsing/source/browse/media/
libmediaplayerservice/MediaPlayerService.cpp?repo=platform--frameworks--base&name=android-4.0.3_r1
698line에서 url에 의해서 playerType을 얻고
702line에서 playerType에 의해
createPlayer를 하고
마지막으로
712line에서 생성된 player에
setDataSource()로 url을 넘깁니다.
같은 파일 MediaPlayerService.cpp에 getPlayerType()이 있고
여기서 url에 따라서 playerType을 결정합니다.
583line에 보듯이 “.m3u8” 주소는 NU_PLAYER를
Return 하게 됩니다.
같은 파일 MediaPlayerService.cpp에 createPlayer()가 있고
넘겨받은 playerType에 의해 player를 creat합니다.

658line : 만든 player가 없으니까 현재 저장된
mPlayer가 null일 것이고 새로 create합니다.
같은 파일 MediaPlayerService.cpp에 또다른 createPlayer()를 보면
넘겨받은 playerType에 의해 player를 creat합니다.

626line : 넘겨받은 playerType이 NU_PLAYER이고
new NuPlayerDriver를 return 합니다.
NuPlayer::setDataSource()는 NuPlayer.cpp
https://code.google.com/p/android-sourcebrowsing/source/browse/media/libmediaplayerservice/nuplayer/NuPlayer.cpp?repo=p
latform--frameworks--base&name=android-4.0.3_r1
에 구현이 돼있습니다.

90,96,100line : kWhatSetDataSource라는
message를 만들고
Object로 url등의 source를 넣고 post합니다.
170line : mSource에 받은 message의 object즉
Url을 담은 source을 넣고 끝냅니다.

Mais conteúdo relacionado

Último

MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionKim Daeun
 
Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Wonjun Hwang
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)Tae Young Lee
 
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Kim Daeun
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Wonjun Hwang
 
캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스
 

Último (6)

MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
 
Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)Console API (Kitworks Team Study 백혜인 발표자료)
Console API (Kitworks Team Study 백혜인 발표자료)
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)
 
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
 
Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)Merge (Kitworks Team Study 이성수 발표자료 240426)
Merge (Kitworks Team Study 이성수 발표자료 240426)
 
캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차
 

Destaque

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Destaque (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

MediaPlayer부터 NuPlayer까지 source trace 자료