Skip to content

Commit e64ba9d

Browse files
author
chenliming
committed
submit source code
1 parent c12a8a7 commit e64ba9d

File tree

383 files changed

+37829
-3035
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

383 files changed

+37829
-3035
lines changed

FrameWork/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.4.3</string>
18+
<string>2.5</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

FrameWork/LFLiveKit.xcodeproj/project.pbxproj

+1,492-16
Large diffs are not rendered by default.

LFLiveKit.podspec

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Pod::Spec.new do |s|
33

44
s.name = "LFLiveKit"
5-
s.version = "2.4.3"
5+
s.version = "2.5"
66
s.summary = "LaiFeng ios Live. LFLiveKit."
77
s.homepage = "https://github.com/chenliming777"
88
s.license = { :type => "MIT", :file => "LICENSE" }
@@ -17,6 +17,4 @@ Pod::Spec.new do |s|
1717
s.libraries = "c++", "z"
1818

1919
s.requires_arc = true
20-
s.dependency 'LMGPUImage'
21-
s.dependency 'pili-librtmp', '1.0.3.1'
2220
end

LFLiveKit/Vendor/GPUImage/GLProgram.m

+236
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
// This is Jeff LaMarche's GLProgram OpenGL shader wrapper class from his OpenGL ES 2.0 book.
2+
// A description of this can be found at his page on the topic:
3+
// http://iphonedevelopment.blogspot.com/2010/11/opengl-es-20-for-ios-chapter-4.html
4+
5+
6+
#import "GLProgram.h"
7+
// START:typedefs
8+
#pragma mark Function Pointer Definitions
9+
typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params);
10+
typedef void (*GLLogFunction) (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
11+
// END:typedefs
12+
#pragma mark -
13+
#pragma mark Private Extension Method Declaration
14+
// START:extension
15+
@interface GLProgram()
16+
17+
- (BOOL)compileShader:(GLuint *)shader
18+
type:(GLenum)type
19+
string:(NSString *)shaderString;
20+
@end
21+
// END:extension
22+
#pragma mark -
23+
24+
@implementation GLProgram
25+
// START:init
26+
27+
@synthesize initialized = _initialized;
28+
29+
- (id)initWithVertexShaderString:(NSString *)vShaderString
30+
fragmentShaderString:(NSString *)fShaderString;
31+
{
32+
if ((self = [super init]))
33+
{
34+
_initialized = NO;
35+
36+
attributes = [[NSMutableArray alloc] init];
37+
uniforms = [[NSMutableArray alloc] init];
38+
program = glCreateProgram();
39+
40+
if (![self compileShader:&vertShader
41+
type:GL_VERTEX_SHADER
42+
string:vShaderString])
43+
{
44+
NSLog(@"Failed to compile vertex shader");
45+
}
46+
47+
// Create and compile fragment shader
48+
if (![self compileShader:&fragShader
49+
type:GL_FRAGMENT_SHADER
50+
string:fShaderString])
51+
{
52+
NSLog(@"Failed to compile fragment shader");
53+
}
54+
55+
glAttachShader(program, vertShader);
56+
glAttachShader(program, fragShader);
57+
}
58+
59+
return self;
60+
}
61+
62+
- (id)initWithVertexShaderString:(NSString *)vShaderString
63+
fragmentShaderFilename:(NSString *)fShaderFilename;
64+
{
65+
NSString *fragShaderPathname = [[NSBundle mainBundle] pathForResource:fShaderFilename ofType:@"fsh"];
66+
NSString *fragmentShaderString = [NSString stringWithContentsOfFile:fragShaderPathname encoding:NSUTF8StringEncoding error:nil];
67+
68+
if ((self = [self initWithVertexShaderString:vShaderString fragmentShaderString:fragmentShaderString]))
69+
{
70+
}
71+
72+
return self;
73+
}
74+
75+
- (id)initWithVertexShaderFilename:(NSString *)vShaderFilename
76+
fragmentShaderFilename:(NSString *)fShaderFilename;
77+
{
78+
NSString *vertShaderPathname = [[NSBundle mainBundle] pathForResource:vShaderFilename ofType:@"vsh"];
79+
NSString *vertexShaderString = [NSString stringWithContentsOfFile:vertShaderPathname encoding:NSUTF8StringEncoding error:nil];
80+
81+
NSString *fragShaderPathname = [[NSBundle mainBundle] pathForResource:fShaderFilename ofType:@"fsh"];
82+
NSString *fragmentShaderString = [NSString stringWithContentsOfFile:fragShaderPathname encoding:NSUTF8StringEncoding error:nil];
83+
84+
if ((self = [self initWithVertexShaderString:vertexShaderString fragmentShaderString:fragmentShaderString]))
85+
{
86+
}
87+
88+
return self;
89+
}
90+
// END:init
91+
// START:compile
92+
- (BOOL)compileShader:(GLuint *)shader
93+
type:(GLenum)type
94+
string:(NSString *)shaderString
95+
{
96+
// CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent();
97+
98+
GLint status;
99+
const GLchar *source;
100+
101+
source =
102+
(GLchar *)[shaderString UTF8String];
103+
if (!source)
104+
{
105+
NSLog(@"Failed to load vertex shader");
106+
return NO;
107+
}
108+
109+
*shader = glCreateShader(type);
110+
glShaderSource(*shader, 1, &source, NULL);
111+
glCompileShader(*shader);
112+
113+
glGetShaderiv(*shader, GL_COMPILE_STATUS, &status);
114+
115+
if (status != GL_TRUE)
116+
{
117+
GLint logLength;
118+
glGetShaderiv(*shader, GL_INFO_LOG_LENGTH, &logLength);
119+
if (logLength > 0)
120+
{
121+
GLchar *log = (GLchar *)malloc(logLength);
122+
glGetShaderInfoLog(*shader, logLength, &logLength, log);
123+
if (shader == &vertShader)
124+
{
125+
self.vertexShaderLog = [NSString stringWithFormat:@"%s", log];
126+
}
127+
else
128+
{
129+
self.fragmentShaderLog = [NSString stringWithFormat:@"%s", log];
130+
}
131+
132+
free(log);
133+
}
134+
}
135+
136+
// CFAbsoluteTime linkTime = (CFAbsoluteTimeGetCurrent() - startTime);
137+
// NSLog(@"Compiled in %f ms", linkTime * 1000.0);
138+
139+
return status == GL_TRUE;
140+
}
141+
// END:compile
142+
#pragma mark -
143+
// START:addattribute
144+
- (void)addAttribute:(NSString *)attributeName
145+
{
146+
if (![attributes containsObject:attributeName])
147+
{
148+
[attributes addObject:attributeName];
149+
glBindAttribLocation(program,
150+
(GLuint)[attributes indexOfObject:attributeName],
151+
[attributeName UTF8String]);
152+
}
153+
}
154+
// END:addattribute
155+
// START:indexmethods
156+
- (GLuint)attributeIndex:(NSString *)attributeName
157+
{
158+
return (GLuint)[attributes indexOfObject:attributeName];
159+
}
160+
- (GLuint)uniformIndex:(NSString *)uniformName
161+
{
162+
return glGetUniformLocation(program, [uniformName UTF8String]);
163+
}
164+
// END:indexmethods
165+
#pragma mark -
166+
// START:link
167+
- (BOOL)link
168+
{
169+
// CFAbsoluteTime startTime = CFAbsoluteTimeGetCurrent();
170+
171+
GLint status;
172+
173+
glLinkProgram(program);
174+
175+
glGetProgramiv(program, GL_LINK_STATUS, &status);
176+
if (status == GL_FALSE)
177+
return NO;
178+
179+
if (vertShader)
180+
{
181+
glDeleteShader(vertShader);
182+
vertShader = 0;
183+
}
184+
if (fragShader)
185+
{
186+
glDeleteShader(fragShader);
187+
fragShader = 0;
188+
}
189+
190+
self.initialized = YES;
191+
192+
// CFAbsoluteTime linkTime = (CFAbsoluteTimeGetCurrent() - startTime);
193+
// NSLog(@"Linked in %f ms", linkTime * 1000.0);
194+
195+
return YES;
196+
}
197+
// END:link
198+
// START:use
199+
- (void)use
200+
{
201+
glUseProgram(program);
202+
}
203+
// END:use
204+
#pragma mark -
205+
206+
- (void)validate;
207+
{
208+
GLint logLength;
209+
210+
glValidateProgram(program);
211+
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength);
212+
if (logLength > 0)
213+
{
214+
GLchar *log = (GLchar *)malloc(logLength);
215+
glGetProgramInfoLog(program, logLength, &logLength, log);
216+
self.programLog = [NSString stringWithFormat:@"%s", log];
217+
free(log);
218+
}
219+
}
220+
221+
#pragma mark -
222+
// START:dealloc
223+
- (void)dealloc
224+
{
225+
if (vertShader)
226+
glDeleteShader(vertShader);
227+
228+
if (fragShader)
229+
glDeleteShader(fragShader);
230+
231+
if (program)
232+
glDeleteProgram(program);
233+
234+
}
235+
// END:dealloc
236+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#import "GPUImage3x3ConvolutionFilter.h"
2+
3+
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
4+
NSString *const kGPUImage3x3ConvolutionFragmentShaderString = SHADER_STRING
5+
(
6+
precision highp float;
7+
8+
uniform sampler2D inputImageTexture;
9+
10+
uniform mediump mat3 convolutionMatrix;
11+
12+
varying vec2 textureCoordinate;
13+
varying vec2 leftTextureCoordinate;
14+
varying vec2 rightTextureCoordinate;
15+
16+
varying vec2 topTextureCoordinate;
17+
varying vec2 topLeftTextureCoordinate;
18+
varying vec2 topRightTextureCoordinate;
19+
20+
varying vec2 bottomTextureCoordinate;
21+
varying vec2 bottomLeftTextureCoordinate;
22+
varying vec2 bottomRightTextureCoordinate;
23+
24+
void main()
25+
{
26+
mediump vec3 bottomColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;
27+
mediump vec3 bottomLeftColor = texture2D(inputImageTexture, bottomLeftTextureCoordinate).rgb;
28+
mediump vec3 bottomRightColor = texture2D(inputImageTexture, bottomRightTextureCoordinate).rgb;
29+
mediump vec4 centerColor = texture2D(inputImageTexture, textureCoordinate);
30+
mediump vec3 leftColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb;
31+
mediump vec3 rightColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb;
32+
mediump vec3 topColor = texture2D(inputImageTexture, topTextureCoordinate).rgb;
33+
mediump vec3 topRightColor = texture2D(inputImageTexture, topRightTextureCoordinate).rgb;
34+
mediump vec3 topLeftColor = texture2D(inputImageTexture, topLeftTextureCoordinate).rgb;
35+
36+
mediump vec3 resultColor = topLeftColor * convolutionMatrix[0][0] + topColor * convolutionMatrix[0][1] + topRightColor * convolutionMatrix[0][2];
37+
resultColor += leftColor * convolutionMatrix[1][0] + centerColor.rgb * convolutionMatrix[1][1] + rightColor * convolutionMatrix[1][2];
38+
resultColor += bottomLeftColor * convolutionMatrix[2][0] + bottomColor * convolutionMatrix[2][1] + bottomRightColor * convolutionMatrix[2][2];
39+
40+
gl_FragColor = vec4(resultColor, centerColor.a);
41+
}
42+
);
43+
#else
44+
NSString *const kGPUImage3x3ConvolutionFragmentShaderString = SHADER_STRING
45+
(
46+
uniform sampler2D inputImageTexture;
47+
48+
uniform mat3 convolutionMatrix;
49+
50+
varying vec2 textureCoordinate;
51+
varying vec2 leftTextureCoordinate;
52+
varying vec2 rightTextureCoordinate;
53+
54+
varying vec2 topTextureCoordinate;
55+
varying vec2 topLeftTextureCoordinate;
56+
varying vec2 topRightTextureCoordinate;
57+
58+
varying vec2 bottomTextureCoordinate;
59+
varying vec2 bottomLeftTextureCoordinate;
60+
varying vec2 bottomRightTextureCoordinate;
61+
62+
void main()
63+
{
64+
vec3 bottomColor = texture2D(inputImageTexture, bottomTextureCoordinate).rgb;
65+
vec3 bottomLeftColor = texture2D(inputImageTexture, bottomLeftTextureCoordinate).rgb;
66+
vec3 bottomRightColor = texture2D(inputImageTexture, bottomRightTextureCoordinate).rgb;
67+
vec4 centerColor = texture2D(inputImageTexture, textureCoordinate);
68+
vec3 leftColor = texture2D(inputImageTexture, leftTextureCoordinate).rgb;
69+
vec3 rightColor = texture2D(inputImageTexture, rightTextureCoordinate).rgb;
70+
vec3 topColor = texture2D(inputImageTexture, topTextureCoordinate).rgb;
71+
vec3 topRightColor = texture2D(inputImageTexture, topRightTextureCoordinate).rgb;
72+
vec3 topLeftColor = texture2D(inputImageTexture, topLeftTextureCoordinate).rgb;
73+
74+
vec3 resultColor = topLeftColor * convolutionMatrix[0][0] + topColor * convolutionMatrix[0][1] + topRightColor * convolutionMatrix[0][2];
75+
resultColor += leftColor * convolutionMatrix[1][0] + centerColor.rgb * convolutionMatrix[1][1] + rightColor * convolutionMatrix[1][2];
76+
resultColor += bottomLeftColor * convolutionMatrix[2][0] + bottomColor * convolutionMatrix[2][1] + bottomRightColor * convolutionMatrix[2][2];
77+
78+
gl_FragColor = vec4(resultColor, centerColor.a);
79+
}
80+
);
81+
#endif
82+
83+
@implementation GPUImage3x3ConvolutionFilter
84+
85+
@synthesize convolutionKernel = _convolutionKernel;
86+
87+
#pragma mark -
88+
#pragma mark Initialization and teardown
89+
90+
- (id)init;
91+
{
92+
if (!(self = [self initWithFragmentShaderFromString:kGPUImage3x3ConvolutionFragmentShaderString]))
93+
{
94+
return nil;
95+
}
96+
97+
self.convolutionKernel = (GPUMatrix3x3){
98+
{0.f, 0.f, 0.f},
99+
{0.f, 1.f, 0.f},
100+
{0.f, 0.f, 0.f}
101+
};
102+
103+
return self;
104+
}
105+
106+
- (id)initWithFragmentShaderFromString:(NSString *)fragmentShaderString;
107+
{
108+
if (!(self = [super initWithFragmentShaderFromString:fragmentShaderString]))
109+
{
110+
return nil;
111+
}
112+
113+
convolutionMatrixUniform = [filterProgram uniformIndex:@"convolutionMatrix"];
114+
115+
return self;
116+
}
117+
118+
#pragma mark -
119+
#pragma mark Accessors
120+
121+
- (void)setConvolutionKernel:(GPUMatrix3x3)newValue;
122+
{
123+
_convolutionKernel = newValue;
124+
125+
[self setMatrix3f:_convolutionKernel forUniform:convolutionMatrixUniform program:filterProgram];
126+
}
127+
128+
@end

0 commit comments

Comments
 (0)