From 52bb65e8ee60b0f2625b7bcee6593478007f36d2 Mon Sep 17 00:00:00 2001 From: toss156 <308276366@qq.com> Date: Fri, 29 Jan 2016 00:04:01 +0800 Subject: [PATCH 1/2] fix iOS Demo bar layout bug for iPhone6 and iPhone6p --- .../IJKMoviePlayerViewController.xib | 73 ++++++++++++++----- .../IJKQRCodeScanViewController.xib | 4 +- 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/ios/IJKMediaDemo/IJKMediaDemo/IJKMoviePlayerViewController.xib b/ios/IJKMediaDemo/IJKMediaDemo/IJKMoviePlayerViewController.xib index 8f7f5dd49b..ef1a29ebc0 100644 --- a/ios/IJKMediaDemo/IJKMediaDemo/IJKMoviePlayerViewController.xib +++ b/ios/IJKMediaDemo/IJKMediaDemo/IJKMoviePlayerViewController.xib @@ -1,5 +1,5 @@ - + @@ -24,21 +24,20 @@ - + - - + - - + - - - - + - + + + @@ -77,26 +77,48 @@ - + + + + + + + + + + + + + + + + + + + + + + - + - @@ -113,12 +135,25 @@ + + + + + + + + + + + + + diff --git a/ios/IJKMediaDemo/IJKMediaDemo/IJKQRCodeScanViewController.xib b/ios/IJKMediaDemo/IJKMediaDemo/IJKQRCodeScanViewController.xib index 113524b9d4..d487859638 100644 --- a/ios/IJKMediaDemo/IJKMediaDemo/IJKQRCodeScanViewController.xib +++ b/ios/IJKMediaDemo/IJKMediaDemo/IJKQRCodeScanViewController.xib @@ -1,8 +1,8 @@ - + - + From 2ba369a53a4df55c6d7cac3bad462acc2bffdbe1 Mon Sep 17 00:00:00 2001 From: toss156 <308276366@qq.com> Date: Fri, 29 Jan 2016 00:13:31 +0800 Subject: [PATCH 2/2] get realtime download speed --- ijkmedia/ijkplayer/ff_ffmsg.h | 2 ++ ijkmedia/ijkplayer/ff_ffplay.c | 15 +++++++++++++++ .../IJKFFMoviePlayerController.m | 19 +++++++++++++++++-- .../IJKMediaPlayer/IJKMediaPlayback.h | 3 +++ .../IJKMediaPlayer/IJKMediaPlayback.m | 2 ++ 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/ijkmedia/ijkplayer/ff_ffmsg.h b/ijkmedia/ijkplayer/ff_ffmsg.h index 592acc757a..22dd41d675 100644 --- a/ijkmedia/ijkplayer/ff_ffmsg.h +++ b/ijkmedia/ijkplayer/ff_ffmsg.h @@ -38,6 +38,8 @@ #define FFP_MSG_BUFFERING_UPDATE 502 /* arg1 = buffering head position in time, arg2 = minimum percent in time or bytes */ #define FFP_MSG_BUFFERING_BYTES_UPDATE 503 /* arg1 = cached data in bytes, arg2 = high water mark */ #define FFP_MSG_BUFFERING_TIME_UPDATE 504 /* arg1 = cached duration in milliseconds, arg2 = high water mark */ +#define FFP_MSG_BUFFERING_SPEED 505 /* arg1 = bytes , arg2 = milliseconds */ + #define FFP_MSG_SEEK_COMPLETE 600 #define FFP_MSG_PLAYBACK_STATE_CHANGED 700 diff --git a/ijkmedia/ijkplayer/ff_ffplay.c b/ijkmedia/ijkplayer/ff_ffplay.c index b0412a3d5d..ebc1e34d17 100644 --- a/ijkmedia/ijkplayer/ff_ffplay.c +++ b/ijkmedia/ijkplayer/ff_ffplay.c @@ -127,6 +127,15 @@ int64_t get_valid_channel_layout(int64_t channel_layout, int channels) static void free_picture(Frame *vp); +//add by feng for [download speed] +static void flush_speed(void *ffp, int64_t bytes, int64_t elapsed_milli) +{ + FFPlayer *lffp = (FFPlayer *)ffp; + if(lffp != NULL) + ffp_notify_msg3(lffp, FFP_MSG_BUFFERING_SPEED, bytes, elapsed_milli); +// ALOGE("realtime calc net speed:%f",speed); +} + static int packet_queue_put_private(PacketQueue *q, AVPacket *pkt) { MyAVPacketList *pkt1; @@ -2456,6 +2465,12 @@ static int read_thread(void *arg) #endif } is->ic = ic; + + //add by feng for [download speed] + if (ic->pb){ + ic->pb->flush_speed = flush_speed; + ic->pb->ffp_opaque = ffp; + } if (ffp->genpts) ic->flags |= AVFMT_FLAG_GENPTS; diff --git a/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m b/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m index 5aac613a12..2a63afb5d0 100644 --- a/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m +++ b/ios/IJKMediaPlayer/IJKMediaPlayer/IJKFFMoviePlayerController.m @@ -57,6 +57,8 @@ @implementation IJKFFMoviePlayerController { BOOL _seeking; NSInteger _bufferingTime; NSInteger _bufferingPosition; + NSInteger _lastSecBufferingByte; + NSInteger _lastSecBufferingElapsedMilli; BOOL _keepScreenOnWhilePlaying; BOOL _pauseInBackground; @@ -77,7 +79,8 @@ @implementation IJKFFMoviePlayerController { @synthesize duration; @synthesize playableDuration; @synthesize bufferingProgress = _bufferingProgress; - +@synthesize lastSecBufferingByte = _lastSecBufferingByte; +@synthesize lastSecBufferingElapsedMilli = _lastSecBufferingElapsedMilli; @synthesize numberOfBytesTransferred = _numberOfBytesTransferred; @synthesize isPreparedToPlay = _isPreparedToPlay; @@ -681,7 +684,7 @@ - (CGFloat)fpsAtOutput } if (bytes <= 0) { - return @"0"; + return @"0 KB/s"; } float bytes_per_sec = ((float)bytes) * 1000.f / elapsed_milli; @@ -756,6 +759,10 @@ - (void)refreshHudView formatedSpeed(_asyncReadSpeedStartup.io_bytes, _asyncReadSpeedStartup.elapsed_milli), formatedSpeed(_asyncReadSpeed.io_bytes, _asyncReadSpeed.elapsed_milli)] forKey:@"async-speed"]; + + [_glView setHudValue:[NSString stringWithFormat:@"%@", + formatedSpeed(_lastSecBufferingByte, _lastSecBufferingElapsedMilli)] + forKey:@"speed"]; } - (void)startHudTimer @@ -1059,6 +1066,14 @@ - (void)postEvent: (IJKFFMoviePlayerMessage *)msg object:self]; break; } + case FFP_MSG_BUFFERING_SPEED: + { + _lastSecBufferingByte = avmsg->arg1; + _lastSecBufferingElapsedMilli = avmsg->arg2; + [[NSNotificationCenter defaultCenter] + postNotificationName:IJKMPMoviePlayerBufferSpeedChangedNotification + object:self]; + } default: // NSLog(@"unknown FFP_MSG_xxx(%d)\n", avmsg->what); break; diff --git a/ios/IJKMediaPlayer/IJKMediaPlayer/IJKMediaPlayback.h b/ios/IJKMediaPlayer/IJKMediaPlayer/IJKMediaPlayback.h index 76a3b02c90..61b0b27de6 100644 --- a/ios/IJKMediaPlayer/IJKMediaPlayer/IJKMediaPlayback.h +++ b/ios/IJKMediaPlayer/IJKMediaPlayer/IJKMediaPlayback.h @@ -79,6 +79,8 @@ typedef NS_ENUM(NSInteger, IJKMPMovieTimeOption) { @property(nonatomic, readonly) NSTimeInterval duration; @property(nonatomic, readonly) NSTimeInterval playableDuration; @property(nonatomic, readonly) NSInteger bufferingProgress; +@property(nonatomic, readonly) NSInteger lastSecBufferingByte; +@property(nonatomic, readonly) NSInteger lastSecBufferingElapsedMilli; @property(nonatomic, readonly) BOOL isPreparedToPlay; @property(nonatomic, readonly) IJKMPMoviePlaybackState playbackState; @@ -147,6 +149,7 @@ IJK_EXTERN NSString *const IJKMPMoviePlayerVideoDecoderOpenNotification; IJK_EXTERN NSString *const IJKMPMoviePlayerFirstVideoFrameRenderedNotification; IJK_EXTERN NSString *const IJKMPMoviePlayerFirstAudioFrameRenderedNotification; +IJK_EXTERN NSString *const IJKMPMoviePlayerBufferSpeedChangedNotification; @end #pragma mark IJKMediaUrlOpenDelegate diff --git a/ios/IJKMediaPlayer/IJKMediaPlayer/IJKMediaPlayback.m b/ios/IJKMediaPlayer/IJKMediaPlayer/IJKMediaPlayback.m index f133d380a0..78e72a9a54 100644 --- a/ios/IJKMediaPlayer/IJKMediaPlayer/IJKMediaPlayback.m +++ b/ios/IJKMediaPlayer/IJKMediaPlayer/IJKMediaPlayback.m @@ -39,6 +39,8 @@ NSString *const IJKMPMoviePlayerFirstVideoFrameRenderedNotification = @"IJKMPMoviePlayerFirstVideoFrameRenderedNotification"; NSString *const IJKMPMoviePlayerFirstAudioFrameRenderedNotification = @"IJKMPMoviePlayerFirstAudioFrameRenderedNotification"; +NSString *const IJKMPMoviePlayerBufferSpeedChangedNotification = @"IJKMPMoviePlayerBufferSpeedChangedNotification"; + @implementation IJKMediaUrlOpenData { NSString *_url; BOOL _handled;