Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Room Park Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav Bogdashkin
Room Park Android
Commits
ee5dbb91
Commit
ee5dbb91
authored
Dec 05, 2019
by
Vladislav Bogdashkin
🎣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added ExoPlayer impl
working source via rtmp still can't handle hsl
parent
e2bbafb7
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
127 additions
and
4 deletions
+127
-4
build.gradle
app/build.gradle
+7
-1
ScreenController.kt
.../roompark/presentation/screen/web_cam/ScreenController.kt
+115
-0
ScreenViewState.kt
...l/roompark/presentation/screen/web_cam/ScreenViewState.kt
+2
-2
webcam_screen.xml
app/src/main/res/layout/webcam_screen.xml
+2
-1
dependencies.gradle
dependencies.gradle
+1
-0
No files found.
app/build.gradle
View file @
ee5dbb91
...
@@ -17,7 +17,7 @@ android {
...
@@ -17,7 +17,7 @@ android {
defaultConfig
{
defaultConfig
{
applicationId
$APPLICATION_ID
applicationId
$APPLICATION_ID
ndk
{
ndk
{
abiFilters
'armeabi-v7a'
,
'arm64-v8a'
abiFilters
'armeabi-v7a'
,
'arm64-v8a'
,
'x86'
}
}
minSdkVersion
minSdkVersion_RoomPark
minSdkVersion
minSdkVersion_RoomPark
targetSdkVersion
targetSdkVersion_RoomPark
targetSdkVersion
targetSdkVersion_RoomPark
...
@@ -147,6 +147,12 @@ dependencies {
...
@@ -147,6 +147,12 @@ dependencies {
implementation
group:
'com.google.code.findbugs'
,
name:
'jsr305'
,
version:
'3.0.2'
implementation
group:
'com.google.code.findbugs'
,
name:
'jsr305'
,
version:
'3.0.2'
//Exo Player
implementation
"com.google.android.exoplayer:exoplayer:$exoPlayerVersion"
implementation
"com.google.android.exoplayer:exoplayer-core:$exoPlayerVersion"
implementation
"com.google.android.exoplayer:exoplayer-hls:$exoPlayerVersion"
implementation
"com.google.android.exoplayer:extension-rtmp:$exoPlayerVersion"
//Tests
//Tests
testImplementation
'junit:junit:4.12'
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test:runner:1.2.0'
androidTestImplementation
'androidx.test:runner:1.2.0'
...
...
app/src/main/java/com/biganto/visual/roompark/presentation/screen/web_cam/ScreenController.kt
View file @
ee5dbb91
package
com.biganto.visual.roompark.presentation.screen.web_cam
package
com.biganto.visual.roompark.presentation.screen.web_cam
import
android.net.Uri
import
android.os.Bundle
import
android.os.Bundle
import
android.view.View
import
android.view.View
import
androidx.core.os.bundleOf
import
androidx.core.os.bundleOf
import
butterknife.BindView
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.R
import
com.biganto.visual.roompark.base.IBottomNavigation
import
com.biganto.visual.roompark.base.IBottomNavigation
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkApplication
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.base.RoomParkMainActivity
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.biganto.visual.roompark.conductor.BigantoBaseController
import
com.google.android.exoplayer2.ExoPlayerFactory
import
com.google.android.exoplayer2.SimpleExoPlayer
import
com.google.android.exoplayer2.ext.rtmp.RtmpDataSourceFactory
import
com.google.android.exoplayer2.source.MediaSource
import
com.google.android.exoplayer2.source.ProgressiveMediaSource
import
com.google.android.exoplayer2.source.hls.DefaultHlsDataSourceFactory
import
com.google.android.exoplayer2.source.hls.HlsMediaSource
import
com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection
import
com.google.android.exoplayer2.trackselection.DefaultTrackSelector
import
com.google.android.exoplayer2.ui.PlayerView
import
com.google.android.exoplayer2.upstream.DefaultBandwidthMeter
import
com.google.android.exoplayer2.upstream.DefaultDataSourceFactory
import
timber.log.Timber
import
javax.inject.Inject
import
javax.inject.Inject
/**
/**
* Created by Vladislav Bogdashkin on 30.09.2019.
* Created by Vladislav Bogdashkin on 30.09.2019.
*/
*/
...
@@ -26,6 +42,11 @@ class WebCamScreenController :
...
@@ -26,6 +42,11 @@ class WebCamScreenController :
constructor
(
id
:
Int
)
:
super
(
bundleOf
(
SELECTED_CAM_INDEX_KEY
to
id
))
constructor
(
id
:
Int
)
:
super
(
bundleOf
(
SELECTED_CAM_INDEX_KEY
to
id
))
@BindView
(
R
.
id
.
webCamPlayerView
)
lateinit
var
playerView
:
PlayerView
lateinit
var
player
:
SimpleExoPlayer
override
fun
onViewBound
(
v
:
View
)
{
override
fun
onViewBound
(
v
:
View
)
{
toolBar
.
hideAll
()
toolBar
.
hideAll
()
...
@@ -80,10 +101,104 @@ class WebCamScreenController :
...
@@ -80,10 +101,104 @@ class WebCamScreenController :
private
fun
render
(
viewState
:
WebCamScreenViewState
.
WebCamsLIstLoaded
){
private
fun
render
(
viewState
:
WebCamScreenViewState
.
WebCamsLIstLoaded
){
val
bandwidthMeter
=
DefaultBandwidthMeter
.
Builder
(
activity
).
build
()
val
videoTrackSelectionFactory
=
AdaptiveTrackSelection
.
Factory
()
val
trackSelector
=
DefaultTrackSelector
(
videoTrackSelectionFactory
)
player
=
ExoPlayerFactory
.
newSimpleInstance
(
activity
!!
,
trackSelector
)
// player.addListener(object : Player.EventListener {
//
// override fun onTimelineChanged(timeline: Timeline?, manifest: Any?, reason: Int) {
// Timber.d("onTimelineChanged: ");
// }
//
// override fun onTracksChanged(
// trackGroups: TrackGroupArray?,
// trackSelections: TrackSelectionArray?
// ) {
// Timber.d("onTracksChanged: ");
// }
//
// override fun onLoadingChanged(isLoading: Boolean) {
// Timber.d("onLoadingChanged: ");
// }
//
// override fun onPlayerStateChanged(playWhenReady: Boolean, playbackState: Int) {
// Timber.d("onPlayerStateChanged: $playWhenReady");
// Timber.d("onPlayerStateChanged: $playbackState")
// Timber.d("onPlayerStateChanged: ${player.isPlaying}")
//
//
// }
//
// override fun onRepeatModeChanged(repeatMode: Int) {
// Timber.d("onRepeatModeChanged: ");
// }
//
// override fun onShuffleModeEnabledChanged(shuffleModeEnabled: Boolean) {
// Timber.d("onShuffleModeEnabledChanged");
// }
//
// override fun onPlayerError(error: ExoPlaybackException?) {
// Timber.d("onPlayerError")
// }
//
// override fun onPositionDiscontinuity(reason: Int) {
// Timber.d("onPositionDiscontinuity")
// }
//
// override fun onPlaybackParametersChanged(playbackParameters: PlaybackParameters?) {
// Timber.d("onPlaybackParametersChanged")
// }
//
// override fun onPlaybackSuppressionReasonChanged(playbackSuppressionReason: Int) {
// Timber.d("onPlaybackSuppressionReasonChanged")
// }
//
// override fun onIsPlayingChanged(isPlaying: Boolean) {
// Timber.d("onIsPlayingChanged")
// }
//
// })
playerView
.
player
=
player
val
sourceUrl
=
viewState
.
camList
.
first
{
it
.
index
==
viewState
.
selectedCamIndex
}.
streams
.
first
().
hls
var
rtmpUrl
=
viewState
.
camList
.
first
{
it
.
index
==
viewState
.
selectedCamIndex
}.
streams
.
first
().
rtmp
// rtmpUrl = "rtmp://room-park.ru:1935/cam2-360/stream"
// Timber.d("source url : ${Uri.parse(rtmpUrl)}")
// val mediaSource = buildMediaSource(Uri.parse(sourceUrl))
val
mediaSource
=
buildRtmps
(
Uri
.
parse
(
rtmpUrl
))
Timber
.
d
(
"source url : ${Uri.parse(sourceUrl)}"
)
Timber
.
d
(
"mediaSource : $mediaSource"
)
player
.
prepare
(
mediaSource
,
true
,
true
)
player
.
playWhenReady
=
true
Timber
.
d
(
" after all: ${player.playbackState}"
)
// player.seekToDefaultPosition()
}
}
override
fun
getLayoutId
():
Int
=
R
.
layout
.
webcam_screen
override
fun
getLayoutId
():
Int
=
R
.
layout
.
webcam_screen
private
fun
buildMediaSource
(
uri
:
Uri
):
MediaSource
{
val
source
=
DefaultDataSourceFactory
(
activity
,
"ua"
)
val
dataSourceFactory
=
DefaultHlsDataSourceFactory
(
source
)
//.createDataSource(DATA_TYPE_DRM)
return
HlsMediaSource
.
Factory
(
dataSourceFactory
)
.
setAllowChunklessPreparation
(
true
)
.
createMediaSource
(
uri
)
}
private
fun
buildRtmps
(
uri
:
Uri
):
MediaSource
{
val
source
=
DefaultDataSourceFactory
(
activity
,
"ua"
)
val
dataSourceFactory
=
RtmpDataSourceFactory
()
return
ProgressiveMediaSource
.
Factory
(
dataSourceFactory
)
.
createMediaSource
(
uri
)
}
}
}
\ No newline at end of file
app/src/main/java/com/biganto/visual/roompark/presentation/screen/web_cam/ScreenViewState.kt
View file @
ee5dbb91
...
@@ -11,7 +11,7 @@ import com.biganto.visual.roompark.util.monades.ExceptionString
...
@@ -11,7 +11,7 @@ import com.biganto.visual.roompark.util.monades.ExceptionString
sealed
class
WebCamScreenViewState
:
BigantoBaseViewState
()
{
sealed
class
WebCamScreenViewState
:
BigantoBaseViewState
()
{
class
Idle
:
WebCamScreenViewState
()
class
Idle
:
WebCamScreenViewState
()
class
WebCamsLIstLoaded
(
camList
:
List
<
WebCamModel
>,
selectedCamIndex
:
Int
)
:
WebCamScreenViewState
()
class
WebCamsLIstLoaded
(
val
camList
:
List
<
WebCamModel
>,
val
selectedCamIndex
:
Int
)
:
WebCamScreenViewState
()
class
CamSelected
(
model
:
WebCamModel
)
:
WebCamScreenViewState
()
class
CamSelected
(
val
model
:
WebCamModel
)
:
WebCamScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
WebCamScreenViewState
()
class
SomeError
(
val
exception
:
ExceptionString
)
:
WebCamScreenViewState
()
}
}
\ No newline at end of file
app/src/main/res/layout/webcam_screen.xml
View file @
ee5dbb91
...
@@ -5,7 +5,8 @@
...
@@ -5,7 +5,8 @@
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<VideoView
<com.google.android.exoplayer2.ui.PlayerView
android:id=
"@+id/webCamPlayerView"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
android:layout_height=
"match_parent"
/>
...
...
dependencies.gradle
View file @
ee5dbb91
...
@@ -23,4 +23,5 @@ ext {
...
@@ -23,4 +23,5 @@ ext {
butterKnifeVersion
=
'10.2.0'
butterKnifeVersion
=
'10.2.0'
daggerVersion
=
'2.25.2'
daggerVersion
=
'2.25.2'
rxRelayVersion
=
'2.1.1'
rxRelayVersion
=
'2.1.1'
exoPlayerVersion
=
"2.10.8"
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment