Code Monkey home page Code Monkey logo

rtmp-wrapper's Introduction

rtmp-wrapper

rtmp-wrapper is a librtmp wrapper library for iOS platform

Getting Started

Install the Prerequisites

  • OS X is requried for all iOS development
  • XCODE from the App Store.
  • GIT is required.
  • CocoaPods is required for the iOS dependency management. You should have ruby installed on your machine before install CocoaPods

Install the library

Source code for the SDK is available on GitHub

$ git clone [email protected]:ifactorylab/rtmp-wrapper.git

Run CocoaPods

CocoaPods installs all dependencies for the library project

$ cd rtmp-wrapper
$ pods install
$ open rtmp-wrapper.xcworkspace

Add rtmp-wrapper to your project

Create a Podfile if not exist, add the line below

pod 'rtmp-wrapper',   '~> 1.0.6'

Publishing RTMP stream

#import "RtmpWrapper.h"

RtmpWrapper *rtmp = [[RtmpWrapper alloc] init];
BOOL ret = [rtmp rtmpOpenWithURL:@"YOUR RTMP PUBLISHING POINT" enableWrite:YES];
if (ret) {    
  NSData *video =
    [NSData dataWithContentsOfURL:[NSURL URLWithString:@"FLV VIDEO URL ON THE NET"]];
  NSLog(@"original video length: %d", [video length]);
  NSUInteger length = [video length];  
  NSUInteger chunkSize = 10 * 5120;
  NSUInteger offset = 0;
  
  // Let's split video to small chunks to publish to media server
  do {
    NSUInteger thisChunkSize = length - offset > chunkSize ? chunkSize : length - offset;
    NSData* chunk = [NSData dataWithBytesNoCopy:(char *)[video bytes] + offset
                                         length:thisChunkSize
                                   freeWhenDone:NO];
    offset += thisChunkSize;
    
    // Write new chunk to rtmp server
    NSLog(@"%d", [rtmp rtmpWrite:chunk]);
    sleep(1);
  } while (offset < length);
}

// Close rtmp connection and release class object
[rtmp rtmpClose];
[rtmp release];

Version detail

1.0.8

  • arc enabled

1.0.6

  • async open / write added
  • autoreconnect removed

1.0.5

  • sigpipe => ignored
  • reconnect function added

1.0.4

  • added connected and autoReconnect

rtmp-wrapper's People

Contributors

minsikzzang avatar b00gizm avatar

Stargazers

Wondong Shin avatar

Watchers

 avatar Wondong Shin avatar James Cloos avatar  avatar

Forkers

depthlove

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.